Skip to content
Create a MD5 hash with hex encoding
JavaScript TypeScript
Branch: master
Clone or download
Latest commit cd4a994 Jul 11, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Require Node.js 8, add TypeScript definition (#12) May 4, 2019
.gitattributes Require Node.js 8, add TypeScript definition (#12) May 4, 2019
.gitignore Require Node.js 8, add TypeScript definition (#12) May 4, 2019
.npmrc Require Node.js 8, add TypeScript definition (#12) May 4, 2019
.travis.yml Require Node.js 8, add TypeScript definition (#12) May 4, 2019
browser.js Fix mismatch between the Node.js and browser version (#14) Jul 11, 2019
index.d.ts
index.js Meta tweaks Jul 11, 2019
index.test-d.ts
license Require Node.js 8, add TypeScript definition (#12) May 4, 2019
package.json 3.0.1 Jul 11, 2019
readme.md
test.js

readme.md

md5-hex Build Status

Create a MD5 hash with hex encoding

Please don't use MD5 hashes for anything sensitive!

Works in the browser too, when used with a bundler like Webpack, Rollup, Browserify.

Checkout hasha if you need something more flexible.

Install

$ npm install md5-hex

Usage

const fs = require('fs');
const md5Hex = require('md5-hex');

const buffer = fs.readFileSync('unicorn.png');

md5Hex(buffer);
//=> '1abcb33beeb811dca15f0ac3e47b88d9'

API

md5Hex(data)

data

Type: Buffer | string | Array<Buffer | string>

Prefer buffers as they're faster to hash, but strings can be useful for small things.

Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.

Related

  • crypto-hash - Tiny hashing module that uses the native crypto API in Node.js and the browser
  • hasha - Hashing made simple
  • hash-obj - Get the hash of an object
You can’t perform that action at this time.