{"id":14460,"library":"base32.js","title":"Base32 Encoding for JavaScript","description":"This package provides implementations for various Base32 encoding schemes, including RFC 4648 and Crockford's Base32, tailored for JavaScript environments. Base32 offers distinct advantages over Base64, such as case-insensitivity, suitability for filenames (as it avoids the '/' character), and an alphabet carefully designed to minimize ambiguous characters (e.g., omitting 1, 8, 0 to prevent confusion with I, B, O). However, this comes at the cost of increased data size, with Base32 representations being approximately 20% larger than Base64. The package is currently at version 0.1.0, suggesting it is either an early-stage project or one that has not seen significant updates or active maintenance in a considerable amount of time, lacking a clear release cadence. It differentiates itself by supporting multiple Base32 variants and providing pre-built files for browser compatibility.","status":"abandoned","version":"0.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/mikepb/base32.js","tags":["javascript","base32","base32hex","crockford","rfc2938","rfc4648","encoding","decoding"],"install":[{"cmd":"npm install base32.js","lang":"bash","label":"npm"},{"cmd":"yarn add base32.js","lang":"bash","label":"yarn"},{"cmd":"pnpm add base32.js","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package primarily targets CommonJS environments, exporting an object containing `Encoder` and `Decoder` classes. The `import base32 from 'base32.js'` syntax is incorrect for this type of CommonJS export in ESM.","wrong":"import base32 from \"base32.js\";","symbol":"base32 (module object)","correct":"const base32 = require(\"base32.js\");"},{"note":"Direct destructuring is the idiomatic and clearer way to access the exported classes within CommonJS modules.","wrong":"const Encoder = require(\"base32.js\").Encoder;","symbol":"{ Encoder, Decoder } (destructured CommonJS)","correct":"const { Encoder, Decoder } = require(\"base32.js\");"},{"note":"When used in an ES Module environment, importing an older CommonJS module that exports an object typically requires a `* as` import to correctly access its named properties like `base32.Encoder`.","wrong":"import base32 from 'base32.js';","symbol":"base32 (ESM interop for CJS module)","correct":"import * as base32 from 'base32.js';"}],"quickstart":{"code":"const base32 = require(\"base32.js\");\n\nconsole.log(\"Encoding a buffer using Crockford Base32 (lowercase)...\");\nconst buf = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // Extended buffer for a more realistic example\nconst encoder = new base32.Encoder({ type: \"crockford\", lc: true });\nconst encodedStr = encoder.write(buf).finalize();\nconsole.log(`Original buffer: [${buf.join(', ')}]`);\nconsole.log(`Encoded string: ${encodedStr}`);\n\nconsole.log(\"\\nDecoding the string back...\");\nconst decoder = new base32.Decoder({ type: \"crockford\" });\nconst decodedBuf = decoder.write(encodedStr).finalize();\nconsole.log(`Decoded buffer: [${decodedBuf.join(', ')}]`);\n\n// Example with default RFC4648 without padding\nconsole.log(\"\\nEncoding with default RFC4648 (no padding)...\");\nconst rfc4648Buf = Buffer.from(\"Hello World\"); // Using Buffer for wider compatibility\nconst rfcEncoder = new base32.Encoder(); // Default is rfc4648, no padding\nconst rfcEncodedStr = rfcEncoder.write(rfc4648Buf).finalize();\nconsole.log(`Original string: ${rfc4648Buf.toString()}`);\nconsole.log(`Encoded RFC4648: ${rfcEncodedStr}`);\n\nconst rfcDecoder = new base32.Decoder();\nconst rfcDecodedBuf = rfcDecoder.write(rfcEncodedStr).finalize();\nconsole.log(`Decoded RFC4648: ${rfcDecodedBuf.toString()});","lang":"javascript","description":"This quickstart demonstrates encoding and decoding binary data using Crockford Base32 and the default RFC4648 (no padding) variant, showcasing the streaming API."},"warnings":[{"fix":"Consider migrating to a more actively maintained Base32 library that supports modern JavaScript environments and provides ongoing security updates. If continued use is necessary, carefully review the source code for vulnerabilities and ensure compatibility with your target environment.","message":"This package is at version 0.1.0 and appears to be unmaintained. There is no active development, explicit support for modern JavaScript features like ES Modules, or official TypeScript types. Users should be aware of potential compatibility issues with newer Node.js versions, build tools, or browser environments, and the absence of security patches.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always remember to call both `.write(data)` and `.finalize()` to process data and retrieve the output from `Encoder` and `Decoder` instances.","message":"The library's API uses a streaming encoder/decoder pattern (`.write().finalize()`), which might be unfamiliar to users expecting direct `encode(input)` and `decode(input)` functions. This pattern requires calling `.write()` with the input data, then `.finalize()` to get the result.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Explicitly configure the `type` and `padding` options in the `Encoder` and `Decoder` constructors to ensure compatibility with your target Base32 standard and padding requirements (e.g., `{ type: 'rfc4648', padding: true }`).","message":"The default Base32 variant is RFC 4648 *without* padding, which might differ from other Base32 implementations that commonly use padding by default. Incorrectly handling padding can lead to decoding errors or incompatible output with other systems.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use `import * as base32 from 'base32.js';` and ensure your bundler or Node.js environment is configured to handle CommonJS interop.","cause":"Attempting to use `require()` in an ES Module (`.mjs` file or `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined"},{"fix":"Use `import * as base32 from 'base32.js';` to import the module object containing `Encoder` and `Decoder`.","cause":"Incorrect ES Module import of the CommonJS module. You might have tried `import base32 from 'base32.js';` which does not correctly capture the module's object export.","error":"TypeError: base32.Encoder is not a constructor"},{"fix":"Ensure both `Encoder` and `Decoder` are initialized with the same `type` and `padding` options. If the encoded string was padded, the decoder must be initialized with `{ padding: true }`. Verify the input string is valid Base32 according to the specified type.","cause":"Mismatch in padding settings between the encoder and decoder, or providing an invalid Base32 string to the decoder.","error":"Error: Missing data at end of buffer"}],"ecosystem":"npm"}