mirror of
https://github.com/emn178/js-sha3.git
synced 2026-08-12 19:41:36 +08:00
array buffer output
This commit is contained in:
@@ -59,6 +59,12 @@
|
||||
expect(keccak_512(new ArrayBuffer(0))).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
||||
});
|
||||
});
|
||||
|
||||
context('when output ArrayBuffer', function() {
|
||||
it('should be equal', function() {
|
||||
expect(keccak_512.buffer('').toHexString()).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('keccak_384', function() {
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
ArrayBuffer.prototype.toHexString = function (argument) {
|
||||
var array = new Uint8Array(this);
|
||||
var hex = '';
|
||||
for(var i = 0;i < array.length;++i) {
|
||||
var c = array[i].toString('16');
|
||||
hex += c.length == 1 ? '0' + c : c;
|
||||
}
|
||||
return hex;
|
||||
};
|
||||
(function(sha3_512, sha3_384, sha3_256, sha3_224) {
|
||||
describe('sha3_512', function() {
|
||||
context('when ascii', function() {
|
||||
@@ -59,6 +68,12 @@
|
||||
expect(sha3_512(new ArrayBuffer(0))).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
||||
});
|
||||
});
|
||||
|
||||
context('when output ArrayBuffer', function() {
|
||||
it('should be equal', function() {
|
||||
expect(sha3_512.buffer('').toHexString()).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('sha3_384', function() {
|
||||
|
||||
Reference in New Issue
Block a user