Skip to content

Commit 1ff9801

Browse files
committed
sha512: add sha512 from sha.js
1 parent d58beeb commit 1ff9801

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

create-hmac.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var createHash = require('./create-hash')
22

3-
var blocksize = 64
4-
var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
3+
var zeroBuffer = new Buffer(128)
4+
zeroBuffer.fill(0)
55

66
module.exports = Hmac
77

@@ -10,6 +10,8 @@ function Hmac (alg, key) {
1010
this._opad = opad
1111
this._alg = alg
1212

13+
var blocksize = (alg === 'sha512') ? 128 : 64
14+
1315
key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
1416

1517
if(key.length > blocksize) {

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function each(a, f) {
2929
}
3030

3131
exports.getHashes = function () {
32-
return ['sha1', 'sha256', 'md5', 'rmd160']
32+
return ['sha1', 'sha256', 'sha512', 'md5', 'rmd160']
3333

3434
}
3535

readme.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ in pure javascript so that it can run in the browser.
1111

1212
Here is the subset that is currently implemented:
1313

14-
* createHash (sha1, sha256, md5, rmd160)
15-
* createHmac (sha1, sha256, md5)
14+
* createHash (sha1, sha256, sha512, md5, rmd160)
15+
* createHmac (sha1, sha256, sha512, md5)
1616
* pbkdf2
1717
* pbkdf2Sync
1818
* randomBytes

0 commit comments

Comments
 (0)