code wiki / (root) / base32.nx

base32.nx

buildroot/runtime/base32.nx

6512 B178 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

base32.nx -- RFC 4648 base32 encoder + decoder. Alphabet: A-Z, 2-7 (case-insensitive on decode). Used by: TOTP 2FA secrets (Google Authenticator, Authy, etc.), Matrix recovery keys, Steam Guard, DNS TXT record binary payload, Base32-encoded Onion v3 addresses (minus checksum). Less efficient than base64 (5/8 vs 3/4 ratio) but phone-typable (no mixed case) and larger alphabet margin of error vs case- sensitive encodings. Format: 8 output chars per 5 input bytes; padding '=' to fill incomplete groups. Unpadded variant tolerated on decode. Invariants: B32_1 Encoder is uppercase-only; decoder accepts both cases. B32_2 Padding reinstated to 8-char groups on encode; missing padding accepted on decode. B32_3 Round-trip exact for any byte sequence.

dependencies 1 imports · 1 importers

syscalls.nx base32.nx totp_uri.nx

imports: syscalls.nx

imported by: totp_uri.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main base32_encode b32_enc_char

structs

none

consts

23const B32_PAD: i64 = 0x3D // '='
24const B32_ERR_BAD: i64 = -1

functions

27func b32_enc_char(v: i64) -> i64 {
called by 1: base32_encode
33func b32_dec_val(c: i64) -> i64 {
called by 1: base32_decode
41func base32_encode(in_bytes: *u8, n: i64, out: *u8) -> i64 {
called by 1: main calls 1: b32_enc_char
106func base32_decode(in_chars: *u8, n: i64, out: *u8) -> i64 {
calls 1: b32_dec_val
171func main() -> i64 {
calls 1: base32_encode