Function encode_check

Source
pub fn encode_check<B>(bytes: B, version: u8) -> Result<String, Error>
where B: AsRef<[u8]>,
Available on crate features check and alloc only.
Expand description

Encodes bytes into a Crockford Base32Check-encoded string.

§Errors

§Panics

This function can panic in one cases:

  • If the encoded output contains non-UTF8 bytes.

All panics indicate implementation issues and should never occur.

§Examples

let bytes = b"usque ad finem";
let version = 22;

// encode bytes with into a string
let encoded = c32::encode_check(bytes, version)?;

let expected = "P7AWVHENJJ0RB441K6JVK5DNJ7J3V5";
assert_eq!(encoded, expected);