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

pbkdf2-sha256

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pbkdf2-sha256 - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

.min-wd

9

CHANGELOG.md

@@ -0,1 +1,10 @@

1.0.0 / 2014-06-09
------------------
- moved tests to fixtures
- removed dev dep `terst` for `assert`
- removed semicolons per http://cryptocoinjs.com/about/contributing/#semicolons
- added `crypto-browserify` for `crypto` dev dep (use with Browserify)
- added TravisCI
- added Coveralls
0.1.1 /2014-02-18

@@ -2,0 +11,0 @@ -----------------

58

lib/pbkdf2.js

@@ -0,52 +1,42 @@

var assert = require('assert')
var crypto = require('crypto')
var crypto = require("crypto");
module.exports = pbkdf2;
function pbkdf2(key, salt, iterations, dkLen) {
var hLen = 32; //SHA256 Mac length
if (dkLen > (Math.pow(2, 32) - 1) * hLen)
throw Error("Requested key length too long");
if (typeof key != 'string' && !Buffer.isBuffer(key))
throw new TypeError('key must a string or Buffer');
if (typeof salt != 'string' && !Buffer.isBuffer(salt))
throw new TypeError('salt must a string or Buffer');
var hLen = 32 //SHA256 Mac length
assert(dkLen <= (Math.pow(2, 32) - 1) * hLen, 'requested key length too long')
assert(typeof key == 'string' || Buffer.isBuffer(key), 'key must be a string or buffer')
assert(typeof salt == 'string' || Buffer.isBuffer(salt), 'key must be a string or buffer')
if (typeof salt == 'string') salt = new Buffer(salt);
if (typeof salt == 'string') salt = new Buffer(salt)
var DK = new Buffer(dkLen);
var DK = new Buffer(dkLen)
var T = new Buffer(hLen)
var block1 = new Buffer(salt.length + 4)
var U = new Buffer(hLen);
var T = new Buffer(hLen);
var block1 = new Buffer(salt.length + 4);
var l = Math.ceil(dkLen / hLen)
var r = dkLen - (l - 1) * hLen
var l = Math.ceil(dkLen / hLen);
var r = dkLen - (l - 1) * hLen;
salt.copy(block1, 0, 0, salt.length);
salt.copy(block1, 0, 0, salt.length)
for (var i = 1; i <= l; i++) {
block1[salt.length + 0] = (i >> 24 & 0xff);
block1[salt.length + 1] = (i >> 16 & 0xff);
block1[salt.length + 2] = (i >> 8 & 0xff);
block1[salt.length + 3] = (i >> 0 & 0xff);
block1.writeUInt32BE(i, salt.length)
U = crypto.createHmac('sha256', key).update(block1).digest();
U.copy(T, 0, 0, hLen);
var U = crypto.createHmac('sha256', key).update(block1).digest()
U.copy(T, 0, 0, hLen)
for (var j = 1; j < iterations; j++) {
U = crypto.createHmac('sha256', key).update(U).digest();
U = crypto.createHmac('sha256', key).update(U).digest()
for (var k = 0; k < hLen; k++) {
T[k] ^= U[k];
T[k] ^= U[k]
}
}
var destPos = (i - 1) * hLen;
var destPos = (i - 1) * hLen
var len = (i == l ? r : hLen)
T.copy(DK, destPos, 0, len);
T.copy(DK, destPos, 0, len)
}
return DK;
}
return DK
}
module.exports = pbkdf2
{
"name": "pbkdf2-sha256",
"version": "0.1.1",
"version": "1.0.0",
"description": "pbkdf2-sha256 is a PBDKF2 implementation using HMAC SHA256",
"main": "./lib/pbkdf2.js",
"scripts": {
"test": "mocha test"
},
"author": "JP Richardson <jprichardson@gmail.com>",
"license": "MIT",
"license": "BSD",
"devDependencies": {
"terst": "0.0.1",
"mocha": "~1.17.1",
"browserify": "~3.30.1"
"browserify": "~3.30.1",
"mochify": "^0.4.2",
"crypto-browserify": "^2.1.8",
"coveralls": "^2.10.0",
"mocha-lcov-reporter": "0.0.1",
"istanbul": "^0.2.11"
},

@@ -27,3 +28,12 @@ "keywords": [

"type": "git"
},
"browser": {
"crypto": "crypto-browserify"
},
"scripts": {
"test": "mocha --ui bdd",
"unit": "./node_modules/.bin/mocha",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js",
"coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info"
}
}
}
pbkdf2-sha256
=============
`pbkdf2-sha256` is a JavaScript implementation of [PBKDF2](http://en.wikipedia.org/wiki/PBKDF2) using the SHA256 HMAC. It's fully compatible with Node.js and the browser (via Browserify).
[![build status](https://secure.travis-ci.org/cryptocoinjs/pbkdf2-sha256.png)](http://travis-ci.org/cryptocoinjs/pbkdf2-sha256)
[![Coverage Status](https://img.shields.io/coveralls/cryptocoinjs/pbkdf2-sha256.svg)](https://coveralls.io/r/cryptocoinjs/pbkdf2-sha256)
[![Version](http://img.shields.io/npm/v/pbkdf2-sha256.svg)](https://www.npmjs.org/package/pbkdf2-sha256)
`pbkdf2-sha256` is a JavaScript implementation of [PBKDF2](http://en.wikipedia.org/wiki/PBKDF2) using the SHA256 HMAC. It's useful as the [Scrypt](http://en.wikipedia.org/wiki/Scrypt) algorithm uses this. It's fully compatible with Node.js and the browser (via Browserify).
Why?

@@ -8,0 +13,0 @@ ----

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