Socket
Socket
Sign inDemoInstall

js-sha256

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-sha256 - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.covignore

10

build/sha256.min.js

@@ -1,5 +0,5 @@

(function(t,I){var u="0123456789abcdef".split(""),F={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15},J=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,
666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=function(g){return G(g,!0)},H=function(g){return G(g,!1)},G=function(g,z){z===I&&(z=!0);var a;a:{for(a=g.length;a--;)if(127<g.charCodeAt(a)){a=!0;break a}a=
!1}if(a){var b=encodeURIComponent(g);a=[];for(var c=0,e=0,r=b.length;c<r;++c){var m=b.charCodeAt(c);a[e>>2]=37==m?a[e>>2]|(F[b.charAt(++c)]<<4|F[b.charAt(++c)])<<(3-e%4<<3):a[e>>2]|m<<(3-e%4<<3);++e}b=(e+8>>6)+1<<4;c=e>>2;a[c]|=128<<(3-e%4<<3);for(c+=1;c<b;++c)a[c]=0;a[b-1]=e<<3}else{a=g.length;e=(a+8>>6)+1<<4;c=[];for(b=0;b<e;++b)c[b]=0;for(b=0;b<a;++b)c[b>>2]|=g.charCodeAt(b)<<(3-b%4<<3);c[b>>2]|=128<<(3-b%4<<3);c[e-1]=a<<3;a=c}e=a;if(z){var c=1779033703,b=3144134277,r=1013904242,m=2773480762,f=
1359893119,v=2600822924,w=528734635;a=1541459225}else c=3238371032,b=914150663,r=812702999,m=4144912697,f=4290775857,v=1750603025,w=1694076839,a=3204075428;for(var A=0,t=e.length;A<t;A+=16){for(var h=[],s,l,d=0;16>d;++d)h[d]=e[A+d];for(d=16;64>d;++d)s=k(h[d-15],7)^k(h[d-15],18)^h[d-15]>>>3,l=k(h[d-2],17)^k(h[d-2],19)^h[d-2]>>>10,h[d]=h[d-16]+s+h[d-7]+l;for(var n=c,x=b,y=r,D=m,p=f,B=v,C=w,E=a,u,d=0;64>d;++d)s=k(n,2)^k(n,13)^k(n,22),l=n&x^n&y^x&y,s+=l,l=k(p,6)^k(p,11)^k(p,25),u=p&B^~p&C,l=E+l+u+J[d]+
h[d]&4294967295,E=C,C=B,B=p,p=D+l,D=y,y=x,x=n,n=l+s;c+=n;b+=x;r+=y;m+=D;f+=p;v+=B;w+=C;a+=E}e=q(c)+q(b)+q(r)+q(m)+q(f)+q(v)+q(w);z&&(e+=q(a));return e},k=function(g,f){return g>>>f|g<<32-f},q=function(g){for(var f="",a=0;4>a;a++)var b=3-a<<3,f=f+(u[g>>b+4&15]+u[g>>b&15]);return f};"undefined"!=typeof module?(f.sha256=f,f.sha224=H,module.exports=f):t&&(t.sha256=f,t.sha224=H)})(this);
(function(x,H){var y="0123456789abcdef".split(""),I=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,
3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],k=function(b,g){return F(b,!0,g)},G=function(b,g){return F(b,!1,g)},F=function(b,g,c){g===H&&(g=!0);var e,d,a,r,t,u,v;if(!c&&/[^\x00-\x7F]/.test(b)){c=[];for(d=e=0;d<b.length;d++)a=b.charCodeAt(d),128>a?c[e++]=a:(2048>a?c[e++]=192|a>>6:(55296>a||57344<=a?c[e++]=224|
a>>12:(a=65536+((a&1023)<<10|b.charCodeAt(++d)&1023),c[e++]=240|a>>18,c[e++]=128|a>>12&63),c[e++]=128|a>>6&63),c[e++]=128|a&63);b=c.length;e=(b+8>>6)+1<<4;d=[];for(a=0;a<e;++a)d[a]=0;for(a=0;a<b;++a)d[a>>2]|=c[a]<<(3-(a&3)<<3);d[a>>2]|=128<<(3-(a&3)<<3);d[e-1]=b<<3}else{c=b.length;e=(c+8>>6)+1<<4;d=[];for(a=0;a<e;++a)d[a]=0;for(a=0;a<c;++a)d[a>>2]|=b.charCodeAt(a)<<(3-(a&3)<<3);d[a>>2]|=128<<(3-(a&3)<<3);d[e-1]=c<<3}c=d;g?(e=1779033703,d=3144134277,a=1013904242,r=2773480762,t=1359893119,u=2600822924,
v=528734635,b=1541459225):(e=3238371032,d=914150663,a=812702999,r=4144912697,t=4290775857,u=1750603025,v=1694076839,b=3204075428);for(var k=0,x=c.length;k<x;k+=16){var h=[],w,m,f;for(f=0;16>f;++f)h[f]=c[k+f];for(f=16;64>f;++f)w=l(h[f-15],7)^l(h[f-15],18)^h[f-15]>>>3,m=l(h[f-2],17)^l(h[f-2],19)^h[f-2]>>>10,h[f]=h[f-16]+w+h[f-7]+m;var n=e,z=d,A=a,D=r,p=t,B=u,C=v,E=b,y;for(f=0;64>f;++f)w=l(n,2)^l(n,13)^l(n,22),m=n&z^n&A^z&A,w+=m,m=l(p,6)^l(p,11)^l(p,25),y=p&B^~p&C,m=E+m+y+I[f]+h[f]&4294967295,E=C,C=
B,B=p,p=D+m,D=A,A=z,z=n,n=m+w;e+=n;d+=z;a+=A;r+=D;t+=p;u+=B;v+=C;b+=E}c=q(e)+q(d)+q(a)+q(r)+q(t)+q(u)+q(v);g&&(c+=q(b));return c},l=function(b,g){return b>>>g|b<<32-g},q=function(b){for(var g="",c=0;4>c;c++)var e=3-c<<3,g=g+(y[b>>e+4&15]+y[b>>e&15]);return g};"undefined"!=typeof module?(k.sha256=k,k.sha224=G,module.exports=k):x&&(x.sha256=k,x.sha224=G)})(this);

@@ -0,1 +1,8 @@

# v0.1.3 / 2015-01-06
* Add bower package.
* Fixed JSHint warnings.
* Add travis.
* Add coveralls.
# v0.1.1 / 2014-07-27

@@ -2,0 +9,0 @@

@@ -1,2 +0,2 @@

Copyright 2014 emn178@gmail.com
Copyright 2014-2015 emn178@gmail.com

@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining

{
"name": "js-sha256",
"version": "0.1.1",
"version": "0.1.2",
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
"main": "src/sha256.js",
"devDependencies": {
"expect.js": "~0.3.1",
"jscoverage": "~0.5.9"
},
"scripts": {
"test": "node tests/node-test.js"
"test": "mocha tests/node-test.js -r jscoverage",
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls"
},

@@ -9,0 +14,0 @@ "repository": {

# js-sha256
[![Build Status](https://api.travis-ci.org/emn178/js-sha256.png)](https://travis-ci.org/emn178/js-sha256)
[![Build Status](https://coveralls.io/repos/emn178/js-sha256/badge.png?branch=master)](https://coveralls.io/r/emn178/js-sha256?branch=master)
[![NPM](https://nodei.co/npm/js-sha256.png?stars&downloads)](https://nodei.co/npm/js-sha256/)
A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.
## Install
## Demo
[SHA256 Online](http://emn178.github.io/online-tools/sha256.html)
[SHA224 Online](http://emn178.github.io/online-tools/sha224.html)
## Download
[Compress](https://raw.github.com/emn178/js-sha256/master/build/sha256.min.js)
[Uncompress](https://raw.github.com/emn178/js-sha256/master/src/sha256.js)
## Installation
You can also install js-sha256 by using Bower.
bower install js-sha256
For node.js, you can use this command to install:

@@ -10,2 +25,7 @@

## Usage
You could use like this:
```JavaScript
sha256('Message to hash');
sha224('Message to hash');
```
If you use node.js, you should require the module first:

@@ -20,7 +40,29 @@ ```JavaScript

```
And you could use like this:
```JavaScript
sha256('Message to hash');
sha224('Message to hash');
```
### Methods
#### sha256(str, asciiOnly)
Hash string to sha256, set asciiOnly to true for better performace if you ensure input is ascii.
##### *str: `String`*
String to hash.
##### *asciiOnly: `Boolean` (default: `false`)*
Specify the string encoding is ASCII.
#### sha224(str, asciiOnly)
Hash string to sha224, set asciiOnly to true for better performace if you ensure input is ascii.
##### *str: `String`*
String to hash.
##### *asciiOnly: `Boolean` (default: `false`)*
Specify the string encoding is ASCII.
## Example

@@ -30,7 +72,7 @@ Code

sha256('');
sha256('The quick brown fox jumps over the lazy dog');
sha256('The quick brown fox jumps over the lazy dog.');
sha256('The quick brown fox jumps over the lazy dog', true);
sha256('The quick brown fox jumps over the lazy dog.', true);
sha224('');
sha224('The quick brown fox jumps over the lazy dog');
sha224('The quick brown fox jumps over the lazy dog.');
sha224('The quick brown fox jumps over the lazy dog', true);
sha224('The quick brown fox jumps over the lazy dog.', true);
```

@@ -58,11 +100,2 @@ Output

## Tests
You can open `tests/index.html` in browser or use node.js to run test
node tests/node-test.js
or
npm test
## Extensions

@@ -69,0 +102,0 @@ ### jQuery

/*
* js-sha256 v0.1.1
* js-sha256 v0.1.2
* https://github.com/emn178/js-sha256
*
* Copyright 2014, emn178@gmail.com
* Copyright 2014-2015, emn178@gmail.com
*

@@ -10,12 +10,6 @@ * Licensed under the MIT license:

*/
(function(root, undefined){
;(function(root, undefined) {
'use strict';
var HEX_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
var HEX_TABLE = {
'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,
'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15,
'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15
};
var HEX_CHARS = '0123456789abcdef'.split('');

@@ -31,45 +25,47 @@ var K =[0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,

var sha256 = function(message) {
return sha2(message, true);
var sha256 = function(message, asciiOnly) {
return sha2(message, true, asciiOnly);
};
var sha224 = function(message) {
return sha2(message, false);
var sha224 = function(message, asciiOnly) {
return sha2(message, false, asciiOnly);
};
var sha2 = function(message, is256) {
if(is256 === undefined)
var sha2 = function(message, is256, asciiOnly) {
if(is256 === undefined) {
is256 = true;
}
var blocks = hasUTF8(message) ? UTF8toBlocks(message) : ASCIItoBlocks(message);
if(is256)
{
var h0 = 0x6a09e667;
var h1 = 0xbb67ae85;
var h2 = 0x3c6ef372;
var h3 = 0xa54ff53a;
var h4 = 0x510e527f;
var h5 = 0x9b05688c;
var h6 = 0x1f83d9ab;
var h7 = 0x5be0cd19;
var blocks, h0, h1, h2, h3, h4, h5, h6, h7;
if(!asciiOnly && /[^\x00-\x7F]/.test(message)) {
blocks = getBlocksFromUtf8(message);
} else {
blocks = getBlocksFromAscii(message);
}
else // 224
{
var h0 = 0xc1059ed8;
var h1 = 0x367cd507;
var h2 = 0x3070dd17;
var h3 = 0xf70e5939;
var h4 = 0xffc00b31;
var h5 = 0x68581511;
var h6 = 0x64f98fa7;
var h7 = 0xbefa4fa4;
if(is256) {
h0 = 0x6a09e667;
h1 = 0xbb67ae85;
h2 = 0x3c6ef372;
h3 = 0xa54ff53a;
h4 = 0x510e527f;
h5 = 0x9b05688c;
h6 = 0x1f83d9ab;
h7 = 0x5be0cd19;
} else { // 224
h0 = 0xc1059ed8;
h1 = 0x367cd507;
h2 = 0x3070dd17;
h3 = 0xf70e5939;
h4 = 0xffc00b31;
h5 = 0x68581511;
h6 = 0x64f98fa7;
h7 = 0xbefa4fa4;
}
for(var i = 0, length = blocks.length;i < length;i += 16)
{
var w = [], s0, s1;
for(var j = 0;j < 16;++j)
for(var i = 0, length = blocks.length;i < length;i += 16) {
var w = [], s0, s1, j;
for(j = 0;j < 16;++j) {
w[j] = blocks[i + j];
for(var j = 16;j < 64;++j)
{
}
for(j = 16;j < 64;++j) {
s0 = rightrotate(w[j - 15], 7) ^ rightrotate(w[j - 15], 18) ^ (w[j - 15] >>> 3);

@@ -90,4 +86,3 @@ s1 = rightrotate(w[j - 2], 17) ^ rightrotate(w[j - 2], 19) ^ (w[j - 2] >>> 10);

for(var j = 0;j < 64;++j)
{
for(j = 0;j < 64;++j) {
s0 = rightrotate(a, 2) ^ rightrotate(a, 13) ^ rightrotate(a, 22);

@@ -121,4 +116,5 @@ maj = (a & b) ^ (a & c) ^ (b & c);

var hex = toHexString(h0) + toHexString(h1)+ toHexString(h2) + toHexString(h3) + toHexString(h4) + toHexString(h5) + toHexString(h6);
if(is256)
if(is256) {
hex += toHexString(h7);
}
return hex;

@@ -132,5 +128,4 @@ };

var toHexString = function(num) {
var hex = "";
for(var i = 0; i < 4; i++)
{
var hex = '';
for(var i = 0; i < 4; i++) {
var offset = 3 - i << 3;

@@ -142,11 +137,27 @@ hex += HEX_CHARS[(num >> (offset + 4)) & 0x0F] + HEX_CHARS[(num >> offset) & 0x0F];

var hasUTF8 = function(message) {
var i = message.length;
while(i--)
if(message.charCodeAt(i) > 127)
return true;
return false;
var getBytesFromUtf8 = function(str) {
var bytes = [], index = 0;
for (var i = 0;i < str.length; i++) {
var c = str.charCodeAt(i);
if (c < 0x80) {
bytes[index++] = c;
} else if (c < 0x800) {
bytes[index++] = 0xc0 | (c >> 6);
bytes[index++] = 0x80 | (c & 0x3f);
} else if (c < 0xd800 || c >= 0xe000) {
bytes[index++] = 0xe0 | (c >> 12);
bytes[index++] = 0x80 | ((c >> 6) & 0x3f);
bytes[index++] = 0x80 | (c & 0x3f);
} else {
c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff));
bytes[index++] = 0xf0 | (c >> 18);
bytes[index++] = 0x80 | ((c >> 12) & 0x3f);
bytes[index++] = 0x80 | ((c >> 6) & 0x3f);
bytes[index++] = 0x80 | (c & 0x3f);
}
}
return bytes;
};
var ASCIItoBlocks = function(message) {
var getBlocksFromAscii = function(message) {
// a block is 32 bits(4 bytes), a chunk is 512 bits(64 bytes)

@@ -156,43 +167,36 @@ var length = message.length;

var blockCount = chunkCount << 4; // chunkCount * 16
var blocks = [];
var i;
for(i = 0;i < blockCount;++i)
var blocks = [], i;
for(i = 0;i < blockCount;++i) {
blocks[i] = 0;
for(i = 0;i < length;++i)
blocks[i >> 2] |= message.charCodeAt(i) << (3 - (i % 4) << 3);
blocks[i >> 2] |= 0x80 << (3 - (i % 4) << 3);
}
for(i = 0;i < length;++i) {
blocks[i >> 2] |= message.charCodeAt(i) << (3 - (i & 3) << 3);
}
blocks[i >> 2] |= 0x80 << (3 - (i & 3) << 3);
blocks[blockCount - 1] = length << 3; // length * 8
return blocks;
};
var UTF8toBlocks = function(message) {
var uri = encodeURIComponent(message);
var blocks = [];
for(var i = 0, bytes = 0, length = uri.length;i < length;++i)
{
var c = uri.charCodeAt(i);
if(c == 37) // %
blocks[bytes >> 2] |= ((HEX_TABLE[uri.charAt(++i)] << 4) | HEX_TABLE[uri.charAt(++i)]) << (3 - (bytes % 4) << 3);
else
blocks[bytes >> 2] |= c << (3 - (bytes % 4) << 3);
++bytes;
}
var chunkCount = ((bytes + 8) >> 6) + 1;
var getBlocksFromUtf8 = function(message) {
var bytes = getBytesFromUtf8(message);
var length = bytes.length;
var chunkCount = ((length + 8) >> 6) + 1;
var blockCount = chunkCount << 4; // chunkCount * 16
var index = bytes >> 2;
blocks[index] |= 0x80 << (3 - (bytes % 4) << 3);
for(var i = index + 1;i < blockCount;++i)
var blocks = [], i;
for(i = 0;i < blockCount;++i) {
blocks[i] = 0;
blocks[blockCount - 1] = bytes << 3; // bytes * 8
}
for(i = 0;i < length;++i) {
blocks[i >> 2] |= bytes[i] << (3 - (i & 3) << 3);
}
blocks[i >> 2] |= 0x80 << (3 - (i & 3) << 3);
blocks[blockCount - 1] = length << 3; // length * 8
return blocks;
};
if(typeof(module) != 'undefined')
{
if(typeof(module) != 'undefined') {
sha256.sha256 = sha256;
sha256.sha224 = sha224;
module.exports = sha256;
}
else if(root)
{
} else if(root) {
root.sha256 = sha256;

@@ -199,0 +203,0 @@ root.sha224 = sha224;

@@ -1,7 +0,4 @@

// this also works:
// sha256 = require('../src/sha256.js');
sha256 = require('../src/sha256.js').sha256;
sha224 = require('../src/sha256.js').sha224;
require('./debug.js');
expect = require('expect.js');
require('./test.js');

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

assert('sha256 1', 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', sha256(''));
assert('sha256 2', 'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592', sha256('The quick brown fox jumps over the lazy dog'));
assert('sha256 3', 'ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c', sha256('The quick brown fox jumps over the lazy dog.'));
assert('sha256 4', '72726d8818f693066ceb69afa364218b692e62ea92b385782363780f47529c21', sha256('中文'));
assert('sha256 5', '53196d1acfce0c4b264e01e8018c989d571351f59e33f055f76ff15b4f0516c6', sha256('aécio'));
assert('sha224 1', 'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', sha224(''));
assert('sha224 2', '730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525', sha224('The quick brown fox jumps over the lazy dog'));
assert('sha224 3', '619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c', sha224('The quick brown fox jumps over the lazy dog.'));
assert('sha224 4', 'dfbab71afdf54388af4d55f8bd3de8c9b15e0eb916bf9125f4a959d4', sha224('中文'));
assert('sha224 5', 'd12841cafd89c534924a839e62bf35a2b5f3717b7802eb19bd8d8e15', sha224('aécio'));
describe('sha256', function() {
describe('ascii', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(sha256('')).to.be('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
expect(sha256('The quick brown fox jumps over the lazy dog')).to.be('d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592');
expect(sha256('The quick brown fox jumps over the lazy dog.')).to.be('ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(sha256('The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.')).to.be('54e73d89e1924fdcd056390266a983924b6d6d461e9470b6cd50bbaf69b5c54c');
});
});
});
describe('UTF8', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(sha256('中文')).to.be('72726d8818f693066ceb69afa364218b692e62ea92b385782363780f47529c21');
expect(sha256('aécio')).to.be('53196d1acfce0c4b264e01e8018c989d571351f59e33f055f76ff15b4f0516c6');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(sha256('訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。')).to.be('81a1472ebdeb09406a783d607ff49ee2fde3e9f44ac1cd158ad8d6ad3c4e69fa');
});
});
});
});
describe('sha224', function() {
describe('ascii', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(sha224('')).to.be('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f');
expect(sha224('The quick brown fox jumps over the lazy dog')).to.be('730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525');
expect(sha224('The quick brown fox jumps over the lazy dog.')).to.be('619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(sha224('The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.')).to.be('4d97e15967391d2e846ea7d21bb480efadbae5868b731e7cc6267006');
});
});
});
describe('UTF8', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(sha224('中文')).to.be('dfbab71afdf54388af4d55f8bd3de8c9b15e0eb916bf9125f4a959d4');
expect(sha224('aécio')).to.be('d12841cafd89c534924a839e62bf35a2b5f3717b7802eb19bd8d8e15');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(sha224('訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。')).to.be('a8cb74a54e6dc6ab6110db3915ba08ffe5e1abafaea78538fa12a626');
});
});
});
});

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