Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhleeeme/basexx
base64, 32 and 16 header-only lib
https://github.com/jhleeeme/basexx
Last synced: about 17 hours ago
JSON representation
base64, 32 and 16 header-only lib
- Host: GitHub
- URL: https://github.com/jhleeeme/basexx
- Owner: JHLeeeMe
- License: wtfpl
- Created: 2024-03-21T23:09:17.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-04-12T10:52:02.000Z (9 months ago)
- Last Synced: 2024-04-12T16:44:13.825Z (9 months ago)
- Language: C++
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BaseXX
Header-only library for various Base Encoding & Decoding algorithms.
includes `Base64`, `Base64-URLsafe`, `Base32`, `Base32-Hex`, and `Base16`.
Based on [RFC4648](https://datatracker.ietf.org/doc/html/rfc4648)### Usage
```cpp
#include "BaseXX.h"int main()
{
std::string str{ "Hello, World!" };{ // Base64[-URLsafe]
std::string encoded_text { base64::encode(str) };
std::string urlsafe_encoded_text{ base64::encode_urlsafe(str) };
std::cout << "Base64 Encoded Text: " << encoded_text << std::endl;
std::cout << "Base64 URLsafe Encoded Text: " << urlsafe_encoded_text << std::endl;std::string decoded_text { base64::decode(encoded_text) };
std::string urlsafe_decoded_text{ base64::decode_urlsafe(urlsafe_encoded_text) };
std::cout << "Base64 Decoded Text: " << decoded_text << std::endl;
std::cout << "Base64 URLsafe Decoded Text: " << urlsafe_decoded_text << std::endl;
}
{ // Base32[-Hex]
std::string encoded_text { base32::encode(str) };
std::string hex_encoded_text{ base32::encode_hex(str) };
std::cout << "Base32 Encoded Text: " << encoded_text << std::endl;
std::cout << "Base32 Hex Encoded Text: " << hex_encoded_text << std::endl;std::string decoded_text { base32::decode(encoded_text) };
std::string hex_decoded_text{ base32::decode_hex(hex_encoded_text) };
std::cout << "Base32 Decoded Text: " << decoded_text << std::endl;
std::cout << "Base32 Hex Decoded Text: " << hex_decoded_text << std::endl;
}
{ // Base16
std::string encoded_text{ base16::encode(str) };
std::cout << "Base16 Encoded Text: " << encoded_text << std::endl;std::string decoded_text{ base16::decode(encoded_text) };
std::cout << "Base16 Decoded Text: " << decoded_text << std::endl;
}return 0;
}
```### Dependencies
This project uses GoogleTest (gtest) for its testing framework. GoogleTest is distributed under the BSD 3-Clause "New" or "Revised" License. For more details, see [GoogleTest's GitHub repository](https://github.com/google/googletest).