add shake algorithm

This commit is contained in:
Yi-Cyuan
2015-09-17 14:57:12 +08:00
parent 61300d2d34
commit 7423f9ef37
11 changed files with 160 additions and 139 deletions
+15 -9
View File
@@ -1,13 +1,13 @@
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) {
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;
};
describe('sha3_512', function() {
context('when ascii', function() {
context('and less than 128 bytes', function() {
@@ -74,6 +74,12 @@ ArrayBuffer.prototype.toHexString = function (argument) {
expect(sha3_512.buffer('').toHexString()).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
});
});
context('#hex', function() {
it('should be equal', function() {
expect(sha3_512.hex('')).to.be(sha3_512(''));
});
});
});
describe('sha3_384', function() {