From cb5b22d0886a0a8c19cf1afeef55a8245357cf20 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 6 Jan 2019 00:20:04 +0100 Subject: Add the base32 crate in version 0.4.0 as a dependency To parse OTP secrets in base32 representation, we need a new dependency: the base32 crate. Import subrepo base32/:base32 at a74cd9246fc0e08d6f5cfcb644bfdf76dd438613 --- base32/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 base32/README.md (limited to 'base32/README.md') diff --git a/base32/README.md b/base32/README.md new file mode 100644 index 0000000..86d9ad9 --- /dev/null +++ b/base32/README.md @@ -0,0 +1,35 @@ +# base32 [![Build Status](https://travis-ci.org/andreasots/base32.svg?branch=master)](https://travis-ci.org/andreasots/base32) + +This library lets you encode and decode in either [RFC4648 Base32](http://en.wikipedia.org/wiki/Base32#RFC_4648_Base32_alphabet) or in [Crockford Base32](http://en.wikipedia.org/wiki/Base32#Crockford.27s_Base32). + +# Usage + +```rust +// crockford base32 +assert_eq!(encode(CrockfordBase32, [0xF8, 0x3E, 0x0F, 0x83, 0xE0]), Vec::from_slice("Z0Z0Z0Z0".to_ascii())); +assert_eq!(decode(CrockfordBase32, "Z0Z0Z0Z0".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x0F, 0x83, 0xE0]); + +// rfc4648 base32 +assert_eq!(encode(RFC4648Base32, [0xF8, 0x3E, 0x7F, 0x83, 0xE7]), Vec::from_slice("7A7H7A7H".to_ascii())); +assert_eq!(decode(RFC4648Base32, "7A7H7A7H".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]); + +// rfc4648 base32 without padding characters (=) +assert_eq!(encode(UnpaddedRFC4648Base32, [0xF8, 0x3E, 0x7F, 0x83, 0xE7]), Vec::from_slice("7A7H7A7H".to_ascii())); +assert_eq!(decode(UnpaddedRFC4648Base32, "7A7H7A7H".to_ascii()).unwrap(), vec![0xF8, 0x3E, 0x7F, 0x83, 0xE7]); +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +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. -- cgit v1.2.1