Function bs62::encode_data[][src]

pub fn encode_data(data: &[u8]) -> String

Encode data with support for leading zeroes by prepending a 0x01 byte to the data.

This is necessary because for base62 encoding, the input data is treated as one lagre number. And as in the decimal system, leading zeroes are ignored (0001337 = 1337).

Algorithm

For how the actual encoding works, see encode_num.

Example

let data = vec![0x13, 0x37];
let encoded = bs62::encode_data(&data);

assert_eq!(encoded, "IKN")