Registry / serialization / blueimp-md5

blueimp-md5

JSON →
library2.19.0jsnpmunverified

blueimp-md5 is a pure JavaScript implementation of the MD5 (Message-Digest Algorithm 5) cryptographic hash function. It is compatible with a wide range of environments, including server-side Node.js applications, client-side web browsers, and module loaders such as RequireJS, Browserify, and webpack. The current stable version is 2.19.0. This library is lightweight with zero external dependencies, making it a self-contained utility for generating MD5 hashes. While highly performant for its purpose, it's crucial to note that MD5 is considered cryptographically broken and should not be used for security-sensitive applications like password hashing or digital signatures, where collisions could be exploited. Its typical use cases include data integrity checks or unique ID generation in non-security contexts.

npm install blueimp-md5
INSTALL
IMPORT
SIG · BLUEIMP-MD5
B
blueimp-md5
serializationjavascriptv2.19.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

md5
import md5 from 'blueimp-md5'
import { md5 } from 'blueimp-md5'
The package exports the md5 function as its default export for ESM consumption. Named imports will fail.
md5
const md5 = require('blueimp-md5')
const { md5 } = require('blueimp-md5')
In CommonJS, the module directly exports the md5 function, so it's assigned to a variable, not destructured.
md5
<!-- In HTML --> <script src="js/md5.min.js"></script> // Then in JS: var hash = md5('value')
When included via a script tag in the browser, the `md5` function is exposed globally.

Demonstrates calculating hex-encoded MD5 hashes, HMAC-MD5 hashes with a key, and raw MD5 outputs for a given string, showing typical API usage.

import md5 from 'blueimp-md5'; // Calculate hex-encoded MD5 hash of a string const value = 'Hello, Checklist Day!'; const hexHash = md5(value); console.log(`Hex MD5 hash for '${value}': ${hexHash}`); // Calculate HMAC-MD5 hash with a key const key = 'secret_key'; const hmacHash = md5(value, key); console.log(`HMAC-MD5 hash with key '${key}': ${hmacHash}`); // Calculate raw MD5 hash const rawHash = md5(value, null, true); console.log(`Raw MD5 hash for '${value}':`, rawHash.split('').map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('')); // Example of usage in a Node.js HTTP server (original CJS example adapted for illustration) // This part demonstrates a typical server-side use case, but the core md5 usage is above. // To run this, save as server.mjs and install 'blueimp-md5'. /* import http from 'http'; import url from 'url'; http.createServer((req, res) => { const parsedUrl = url.parse(req.url, true); const query = parsedUrl.query.value || ''; res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(md5(query)); }).listen(8080, 'localhost', () => { console.log('Server running at http://localhost:8080/'); console.log('Try: http://localhost:8080/?value=test'); }); */
Debug
Known issues
gotchaMD5 is cryptographically broken and should NOT be used for security-sensitive applications such as password hashing, digital signatures, or any context where collision resistance is critical. Consider SHA-256 or bcrypt for secure hashing needs.
fix
For security-sensitive applications, migrate to algorithms like SHA-256 (e.g., Node.js `crypto` module) or bcrypt (for passwords).
affects: >=1.0.0
gotchaWhen using the `raw` output option (third argument `true`), the function returns a string of raw bytes (characters with char codes representing byte values), not a hex-encoded string. This can be unexpected if you assume all outputs are hex.
fix
Always check the third argument when using `md5()`. If `true`, handle the output as a raw byte string. Convert it to hex if needed, e.g., `md5('value', null, true).split('').map(c => c.charCodeAt(0).toString(16).padStart(2, '0')).join('')`.
affects: >=1.0.0
gotchaIn browser environments, including `md5.min.js` via a `<script>` tag adds a global `md5` function. This can lead to naming conflicts if another script also defines `md5` or a similar global variable.
fix
When using multiple scripts, be mindful of global namespace pollution. Consider using module bundlers like webpack or Browserify to encapsulate dependencies and avoid global variable conflicts.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: md5 is not defined
Attempting to call `md5()` in a browser environment without including the script, or in a Node.js/ESM environment without correctly importing/requiring the module.
fix
In browsers, ensure `<script src="md5.min.js"></script>` is present before `md5()` is called. In CommonJS, use `const md5 = require('blueimp-md5')`. In ESM, use `import md5 from 'blueimp-md5'`.
TypeError: md5 is not a function
Incorrect ES module import syntax (e.g., `import { md5 } from 'blueimp-md5'`) or CommonJS destructuring (e.g., `const { md5 } = require('blueimp-md5')`), as the package exports the function as the default.
fix
For ESM, use `import md5 from 'blueimp-md5'`. For CommonJS, use `const md5 = require('blueimp-md5')`.
ReferenceError: require is not defined
Attempting to use `require('blueimp-md5')` in a browser environment without a CommonJS-compatible module loader (like Browserify or webpack).
fix
For browser use, either include the library directly via a `<script>` tag or use a module bundler that processes CommonJS `require` statements.
Upgrade
Version history
2.19.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
blueimp-md5 — npm install blueimp-md5 · libregistry