pax_global_header00006660000000000000000000000064130361440670014516gustar00rootroot0000000000000052 comment=5d8f3a88b2de9bfdf7e4f07f253dd88c102814df md5-hex-2.0.0/000077500000000000000000000000001303614406700127645ustar00rootroot00000000000000md5-hex-2.0.0/.editorconfig000066400000000000000000000002761303614406700154460ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 md5-hex-2.0.0/.gitattributes000066400000000000000000000000351303614406700156550ustar00rootroot00000000000000* text=auto *.js text eol=lf md5-hex-2.0.0/.gitignore000066400000000000000000000000151303614406700147500ustar00rootroot00000000000000node_modules md5-hex-2.0.0/.travis.yml000066400000000000000000000000671303614406700151000ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' md5-hex-2.0.0/browser.js000066400000000000000000000002551303614406700150070ustar00rootroot00000000000000'use strict'; const md5OMatic = require('md5-o-matic'); module.exports = input => { if (Array.isArray(input)) { input = input.join(''); } return md5OMatic(input); }; md5-hex-2.0.0/index.js000066400000000000000000000007351303614406700144360ustar00rootroot00000000000000'use strict'; const crypto = require('crypto'); module.exports = function (input) { const hash = crypto.createHash('md5'); const update = buf => { const inputEncoding = typeof buf === 'string' ? 'utf8' : undefined; hash.update(buf, inputEncoding); }; if (arguments.length > 1) { throw new Error('Too many arguments. Try specifying an array.'); } if (Array.isArray(input)) { input.forEach(update); } else { update(input); } return hash.digest('hex'); }; md5-hex-2.0.0/license000066400000000000000000000021371303614406700143340ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. md5-hex-2.0.0/package.json000066400000000000000000000012311303614406700152470ustar00rootroot00000000000000{ "name": "md5-hex", "version": "2.0.0", "description": "Create a MD5 hash with hex encoding", "license": "MIT", "repository": "sindresorhus/md5-hex", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js", "browser.js" ], "keywords": [ "hash", "crypto", "md5", "hex", "buffer", "browser", "browserify" ], "dependencies": { "md5-o-matic": "^0.1.1" }, "devDependencies": { "ava": "*", "xo": "*" }, "browser": "browser.js" } md5-hex-2.0.0/readme.md000066400000000000000000000017541303614406700145520ustar00rootroot00000000000000# md5-hex [![Build Status](https://travis-ci.org/sindresorhus/md5-hex.svg?branch=master)](https://travis-ci.org/sindresorhus/md5-hex) > Create a MD5 hash with hex encoding *Please don't use MD5 hashes for anything sensitive!* Works in the browser too, when used with browserify/webpack. Checkout [`hasha`](https://github.com/sindresorhus/hasha) if you need something more flexible. ## Install ``` $ npm install --save md5-hex ``` ## Usage ```js const fs = require('fs'); const md5Hex = require('md5-hex'); const buffer = fs.readFileSync('unicorn.png'); md5Hex(buffer); //=> '1abcb33beeb811dca15f0ac3e47b88d9' ``` ## API ### md5Hex(input) #### input Type: `Buffer` `string` `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. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) md5-hex-2.0.0/test.js000066400000000000000000000006301303614406700143000ustar00rootroot00000000000000import test from 'ava'; import m from './'; test(t => { t.is(m('unicorn'), '1abcb33beeb811dca15f0ac3e47b88d9'); t.is(m(new Buffer('unicorn')), '1abcb33beeb811dca15f0ac3e47b88d9'); t.is(m(['uni', 'corn']), '1abcb33beeb811dca15f0ac3e47b88d9'); t.is(m(['uni', new Buffer('corn')]), '1abcb33beeb811dca15f0ac3e47b88d9'); t.throws(() => m('uni', 'corn'), 'Too many arguments. Try specifying an array.'); });