Skip to main content

encode_v1

Function encode_v1 

Source
pub fn encode_v1(code: &[u8; 24]) -> String
Expand description

Encodes a version-1 pairing token: the 24-byte dynamic pairing code as base32.

code is the qr_code emission format of a dynamic pairing code, the first 24 bytes of the derivation digest. A display renders the returned string as a QR code; the server decodes it and takes the payload as the entered code.

ยงExample

use syncspin_core::pairing::token::encode_v1;

// The spec's reference vector: the code 0xe0..=0xf7.
let code: [u8; 24] = std::array::from_fn(|index| 0xe0 + index as u8);
assert_eq!(
    encode_v1(&code),
    "SP:14DQ6FY7E4XTOP9HJ5LV6Z3PO57YPD4XT6T97N5Y"
);