Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rev-hash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rev-hash - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

10

index.js
'use strict';
var crypto = require('crypto');
const crypto = require('crypto');
module.exports = function (buf) {
if (!Buffer.isBuffer(buf)) {
throw new TypeError('Expected a buffer');
module.exports = input => {
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
throw new TypeError('Expected a Buffer or string');
}
return crypto.createHash('md5').update(buf).digest('hex').slice(0, 10);
return crypto.createHash('md5').update(input).digest('hex').slice(0, 10);
};
{
"name": "rev-hash",
"version": "1.0.0",
"version": "2.0.0",
"description": "Create a hash for file revving",

@@ -13,6 +13,6 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "node test.js"
"test": "xo && ava"
},

@@ -30,2 +30,3 @@ "files": [

"buffer",
"string",
"file",

@@ -36,4 +37,5 @@ "cache",

"devDependencies": {
"ava": "0.0.4"
"ava": "*",
"xo": "*"
}
}

@@ -5,9 +5,11 @@ # rev-hash [![Build Status](https://travis-ci.org/sindresorhus/rev-hash.svg?branch=master)](https://travis-ci.org/sindresorhus/rev-hash)

It will create a `md5` hash from the input buffer and slice it to 10 characters, which is unique enough for this purpose. If you think you need a different hash algorithm or a longer hash, [you're wrong](http://blog.risingstack.com/automatic-cache-busting-for-your-css/).
It will create an `md5` hash from an input buffer or string, and truncate it to 10 characters, which is unique enough for this purpose.
If you think you need a different hash algorithm or a longer hash, [you're wrong](http://blog.risingstack.com/automatic-cache-busting-for-your-css/).
## Install
```
$ npm install --save rev-hash
$ npm install rev-hash
```

@@ -19,13 +21,26 @@

```js
var fs = require('fs');
var revHash = require('rev-hash');
var buffer = fs.readFileSync('unicorn.png');
const fs = require('fs');
const revHash = require('rev-hash');
revHash(buffer);
revHash(fs.readFileSync('unicorn.png'));
//=> 'bb9d8fe615'
revHash('Lorem ipsum dolor sit amet');
//=> 'fea80f2db0'
```
## API
### revHash(input)
#### input
Type: `Buffer` `string`
Data to create a hash from.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc