#codec #base64 #utf-8 #decode #encode #no-std

no-std basenc

Encoding and decoding of Base-N encodings, no_std compatible

3 unstable releases

new 0.2.1 Dec 11, 2024
0.2.0 Dec 5, 2024
0.1.0 Dec 1, 2016

#1389 in Encoding

Download history 5/week @ 2024-09-23 4/week @ 2024-11-04 133/week @ 2024-12-02

133 downloads per month

MIT license

73KB
1.5K SLoC

BaseNC

MIT License crates.io docs.rs Build status

Pronounced "Base-En-See".

Encoding and decoding hex, base64 and base32 with support for #[no_std].

Examples

Encoding:

let encoded = basenc::Base64Std.encode(b"hello world", basenc::Padding::Optional);
assert_eq!(encoded, "aGVsbG8gd29ybGQ");

Decoding:

let decoded = basenc::Base64Std.decode("aGVsbG8gd29ybGQ=", basenc::Padding::Optional).unwrap();
assert_eq!(decoded, b"hello world");

Features

  • std (default) - Enable support for the standard library. This enables convenience features to encode and decode to String and Vec<u8> buffers.

  • simd-off - Disable SIMD acceleration. The SIMD codepaths are less tested and are more likely to contain bugs.

  • simd-runtime - Enable runtime detection of SIMD support. This is enabled by default and will automatically use SIMD acceleration if available.

Build with RUSTFLAGS="-C target-cpu=native" (bash) / set RUSTFLAGS=-C target-cpu=native (cmd) to enable compiletime detection of SIMD capabilities.

Future work

Profile and optimize for performance.

Implement SIMD accelerated algorithms for encoding and decoding.

License

Licensed under MIT License, see license.txt.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.

Dependencies