10 releases

Uses old Rust 2015

0.5.1 Jul 18, 2024
0.4.0 Oct 23, 2018
0.3.1 Jan 11, 2016
0.3.0 Apr 8, 2015
0.1.1 Nov 22, 2014

#37 in Encoding

Download history 50714/week @ 2024-07-27 51570/week @ 2024-08-03 50899/week @ 2024-08-10 62301/week @ 2024-08-17 65741/week @ 2024-08-24 62003/week @ 2024-08-31 64254/week @ 2024-09-07 54215/week @ 2024-09-14 62945/week @ 2024-09-21 70796/week @ 2024-09-28 65620/week @ 2024-10-05 75988/week @ 2024-10-12 70266/week @ 2024-10-19 78330/week @ 2024-10-26 69820/week @ 2024-11-02 64810/week @ 2024-11-09

296,578 downloads per month
Used in 410 crates (133 directly)

MIT/Apache

22KB
489 lines

base32

This library lets you encode and decode various Base32 variants. #[no_std] compatible but requires a global allocator with the alloc crate.

Usage

use base32::Alphabet;

// Crockford's Base32
assert_eq!(base32::encode(Alphabet::Crockford, &[0xF8, 0x3E, 0x0F, 0x83, 0xE0]), "Z0Z0Z0Z0");
assert_eq!(base32::decode(Alphabet::Crockford, "Z0Z0Z0Z0").unwrap(), vec![0xF8, 0x3E, 0x0F, 0x83, 0xE0]);

// RFC4648
assert_eq!(base32::encode(Alphabet::Rfc4648 { padding: true }, &[0xF8, 0x3E, 0x7F, 0x83, 0xE7]), "7A7H7A7H");
assert_eq!(base32::decode(Alphabet::Rfc4648 { padding: true }, "7A7H7A7H").unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]);

// RFC4648 base32hex
assert_eq!(base32::encode(Alphabet::Rfc4648Hex { padding: true }, &[0xF8, 0x3E, 0x7F, 0x83, 0xE7]), "V0V7V0V7");
assert_eq!(base32::decode(Alphabet::Rfc4648Hex { padding: true }, "V0V7V0V7").unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]);

// z-base-32
assert_eq!(base32::encode(Alphabet::Z, &[0xF8, 0x3E, 0x7F, 0x83, 0xE7]), "9y989y98");
assert_eq!(base32::decode(Alphabet::Z, "9y989y98").unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]);

License

Licensed under either of

at your option.

Contribution

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

No runtime deps