Base64
Prefer the UTF-8 or Base64URL APIs in new code:
import { decodeBase64, encodeBase64, encodeBase64Url } from "@fast-china/utils";
const encoded = encodeBase64('{"name":"Fast utilities"}');
const decoded = decodeBase64(encoded);
decoded;
decoded.parseJson<{ name: string }>();
encodeBase64Url("path/value");encodeSecureBase64 and decodeSecureBase64 apply reversible text obfuscation using a custom dictionary and prefix; they are not encryption. Use the UTF-8 Base64 or Base64URL methods above for general text transport. Neither encoding nor obfuscation protects passwords, tokens, or other secrets.
Starting with 2.1.12, random integers use quotient subtraction for the remainder while retaining random sources, rejection sampling, and half-open interval semantics. SecureBase64 still uses a six-letter default prefix and the same fixed dictionary. Invalid random indices make the encoder throw Error instead of returning a truncated prefix. Local.set / Session.set with the Base64 codec throw TypeError before writing and retain the encoding error as cause, leaving existing stored values intact.
Upgrading does not repair entries whose prefixes are already missing characters. Applications must validate recovered values before encoding them again with the original format, or handle unrecoverable entries individually. Prioritize recovery and validation of installation identifiers to avoid unintentionally replacing an identity. Do not change the public decoder to a five-character default or automatically try different prefix lengths.
