[Pkg-javascript-commits] [node-ripemd160] 14/71: returns `Buffer` type now, input must be Array, Uint8Array, or Buffer
Bastien Roucariès
rouca at moszumanska.debian.org
Thu May 4 10:25:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-ripemd160.
commit b2e0d90cd312a5dbb4dc18ceaf6095e12529806b
Author: JP Richardson <jprichardson at gmail.com>
Date: Sun Mar 9 11:23:05 2014 -0500
returns `Buffer` type now, input must be Array, Uint8Array, or Buffer
---
CHANGELOG.md | 1 +
lib/ripemd160.js | 10 ++--------
test/ripemd160.test.js | 4 ++--
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47cc8eb..cc65121 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
------------------
* removed bower.json and component.json
* changed 4 spacing to 2
+* returns `Buffer` type now, input must be Array, Uint8Array, or Buffer
0.1.0 / 2013-11-20
------------------
diff --git a/lib/ripemd160.js b/lib/ripemd160.js
index 84ac3a9..df519a1 100644
--- a/lib/ripemd160.js
+++ b/lib/ripemd160.js
@@ -172,11 +172,7 @@ function rotl(x,n) {
return (x<<n) | (x>>>(32-n));
}
-function ripemd160(message, options) {
- if (message.constructor === String) {
- message = _imports.convertString.UTF8.stringToBytes(message);
- }
-
+function ripemd160(message) {
var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
var m = bytesToWords(message);
@@ -205,9 +201,7 @@ function ripemd160(message, options) {
}
var digestbytes = wordsToBytes(H);
- return options && options.asBytes ? digestbytes :
- options && options.asString ? _imports.convertString.bytesToString(digestbytes) :
- _imports.bytesToHex(digestbytes);
+ return new Buffer(digestbytes);
}
diff --git a/test/ripemd160.test.js b/test/ripemd160.test.js
index b00409d..99a1411 100644
--- a/test/ripemd160.test.js
+++ b/test/ripemd160.test.js
@@ -5,8 +5,8 @@ require('terst')
describe('+ ripemd160(input)', function() {
describe('> when input is a string', function() {
it('should compute the ripemd160 hash', function() {
- var input = "hello"
- EQ (ripemd160(input), "108f07b8382412612c048d07d13f814118445acd")
+ var input = new Buffer("hello");
+ EQ (ripemd160(input).toString('hex'), "108f07b8382412612c048d07d13f814118445acd")
})
})
})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ripemd160.git
More information about the Pkg-javascript-commits
mailing list