SlugEncode
Author: [silene, 0x20CB, DionysianMYST]
License: APACHE 2.0 or MIT
Description
SlugAPI is a module that provides a unified interface for encoding and decoding various formats such as Hex, Base32, Base58, and Base64 in a constant-time manner. It is designed to be efficient and secure, making it suitable for cryptographic applications.
SlugEncode is an open-source, swiss-army knife for encoding in constant-time for base32, base64, and hexadecimal, as well as encoding for base58. It uses traits to allow the conversion between encodings, as well as provides a builder struct that can be used to encode/decode data in a simple manner. Due to them being constant-time, excluding Base58, it may be more suitable for certain applications.
Developer Notes
The traits can be implemented or the struct can be used to encode different data easily and more efficiently in constant-time with zeroize support. It includes support for:
Constant-Time
-
Hexadecimal
-
Base32
-
Base32 (Padded)
-
Base64
-
Base64 (URL SAFE)
Not-Constant Time
-
Base58
-
Base85
TODO
- Add Zeroize (Feature)
- Add Large Unsigned Intergers (Feature)
- Try Get Encoding (Feature)
- Integrity-Check (Feature)
- Expansion on Traits
Usage
SlugEncodingUsage: A Simple Way To Encode/Decode Data
In this example, we import the slugencode prelude to easily take care of encoding/decoding.
//! In this example, we import the slugencode prelude, take a hex string, and then decode using the "SlugEncodingUsage" struct as opposed to using traits like "TRAIT::SlugEncoder" or "TRAIT::SlugDecoder".
//!
//! It returns a vector of bytes (that are decoded hexadecimal).
//!
//! This can be applied to any encodings listed.
use *;
SlugEncoder/SlugDecoder: Traits That Can Be Implemented To Encode/Decode Data
In this example, we use the traits slugencoder and slugdecoder to encode/decode data. It encodes data from bytes while it decodes from strings.
Once the trait is imported, it can be used right away.
// Import Traits
use SlugEncoder;
use SlugDecoder;
Contributions
Contributions are welcome :)
License
APACHE 2.0 OR MIT