Expand description

A simple module containing 2 functions to encode and decode the secrets generated by this crate’s generate_secret function to and from the given encoding available in the data_encoding crate.

Example

use thotp::encoding::{encode, decode};
use thotp::generate_secret;

let buffer = generate_secret(160);

let encoded = encode(&buffer, data_encoding::BASE32);

let decoded: [u8; 160] =
  decode(&encoded, data_encoding::BASE32)
  .unwrap()
  .try_into()
  .unwrap();

assert_eq!(buffer, decoded)

Re-exports

pub use data_encoding;

Functions

Decodes the provided string from the encoding of choice. Useful for decoding encoded secrets generated with this crate’s generate_secret and encode functions.
Encodes the provided buffer to the encoding of choice. Useful for encoding secret buffers generated by this crate’s generate_secret function.