encode32 is a utility for Base32 encoding 32-bit unsigned integers, drawing inspiration from Douglas Crockford's Base32 specification. Released as version 1.1.0, its release cadence is effectively abandoned, with the last publish being over 8 years ago and targeting Node.js versions as old as 0.4.7. Key differentiators include its design for human-friendliness and robustness, using 32 digits with case-insensitivity and aliases for easily confused characters (e.g., 'l' and 'I' for '1', 'o' for '0'). It notably excludes the character 'U' to avoid accidental obscenities. Instead of Crockford's suggested 'mod 37 checksum', this implementation incorporates a 3-bit parity checksum into the final character, enabling quick sanity checks without increasing length, but making it incompatible with other standard Base32 implementations. It is specifically designed for 32-bit numbers, though later additions (mentioned in the original README) hinted at support for up to 53-bit numbers with parity.
npm install encode32Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates encoding a 32-bit integer, decoding its case-insensitive and aliased variations, and shows how invalid inputs fail the parity check, resulting in `NaN`.
If interoperability with other Crockford Base32 implementations is required, consider alternatives like `base32-encode` or `ts-base32` which explicitly support the Crockford variant, or implement a compatible checksum/no-checksum logic manually.
For new projects or critical applications, consider using actively maintained Base32 libraries that support the Crockford variant, such as `base32-encode` or `ts-base32`, which offer more robust and up-to-date solutions.
Validate input numbers to ensure they fit within a 32-bit unsigned integer range (0 to 4,294,967,295). For larger integers (e.g., 64-bit IDs), use libraries designed for arbitrary-precision integers or those that explicitly support `BigInt` for encoding.
Ensure the package is imported using `require()` syntax. If your project is pure ESM, you may need to wrap `require()` or use a different Base32 library that provides ESM support.
If in an ESM file, convert `import { encode32, decode32 } from 'encode32';` to `const { encode32, decode32 } = await import('encode32');` or, preferably, switch to a modern library that officially supports ESM. If in a CJS file, ensure `require()` is used correctly.Ensure the input string is a correctly formatted 7-character Base32 string that was originally encoded by this library, and verify no characters are transposed or missing. The library's parity check is strict.
Pre-validate numbers to ensure they are within the 32-bit unsigned integer range (0 to 4,294,967,295) before passing them to `encode32`. For larger numbers, use a `BigInt`-compatible or 64-bit encoding library.
No dependency data recorded yet.