nx_base32.nx
buildroot/runtime/nx_base32.nx
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 · 2 importers
imports: nx_syscalls.nx
imported by: nx_mfa.nxnx_totp_uri.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 29 | const B32_PAD: i64 = 0x3D // '=' |
| 30 | const B32_ERR_BAD: i64 = -1 |
functions
| 33 | func b32_enc_char(v: i64) -> i64 called by 1: base32_encode |
| 39 | func b32_dec_val(c: i64) -> i64 called by 1: base32_decode |
| 47 | func base32_encode(in_bytes: *u8, n: i64, out: *u8) -> i64 |
| 112 | func base32_decode(in_chars: *u8, n: i64, out: *u8) -> i64 |
| 177 | func main() -> i64 |