Comparing version
{ | ||
"name": "js-sha256", | ||
"version": "0.2.3", | ||
"main": ["build/sha256.min.js"], | ||
"version": "0.3.0", | ||
"main": ["src/sha256.js"], | ||
"ignore": [ | ||
@@ -6,0 +6,0 @@ "samples", |
@@ -0,1 +1,5 @@ | ||
# v0.3.0 / 2015-05-23 | ||
* Support ArrayBuffer input. | ||
# v0.2.3 / 2015-02-11 | ||
@@ -2,0 +6,0 @@ |
@@ -1,3 +0,5 @@ | ||
Copyright 2014-2015 emn178@gmail.com | ||
Copyright (c) 2015 Chen Yi-Cyuan | ||
MIT License | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
@@ -4,0 +6,0 @@ a copy of this software and associated documentation files (the |
{ | ||
"name": "js-sha256", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.", | ||
@@ -5,0 +5,0 @@ "main": "src/sha256.js", |
@@ -71,3 +71,3 @@ # js-sha256 | ||
It also supports byte Array or Uint8Array input: | ||
It also supports byte `Array`, `Uint8Array`, `ArrayBuffer` input: | ||
@@ -74,0 +74,0 @@ Code |
/* | ||
* js-sha256 v0.2.3 | ||
* js-sha256 v0.3.0 | ||
* https://github.com/emn178/js-sha256 | ||
@@ -32,7 +32,2 @@ * | ||
Array.prototype.__ARRAY__ = true; | ||
if(TYPED_ARRAY) { | ||
Uint8Array.prototype.__ARRAY__ = true; | ||
} | ||
var sha224 = function(message) { | ||
@@ -43,2 +38,7 @@ return sha256(message, true); | ||
var sha256 = function(message, is224) { | ||
var notString = typeof(message) != 'string'; | ||
if(notString && message.constructor == root.ArrayBuffer) { | ||
message = new Uint8Array(message); | ||
} | ||
var h0, h1, h2, h3, h4, h5, h6, h7, block, code, first = true, end = false, | ||
@@ -74,3 +74,3 @@ i, j, index = 0, start = 0, bytes = 0, length = message.length, | ||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; | ||
if(message.__ARRAY__) { | ||
if(notString) { | ||
for (i = start;index < length && i < 64; ++index) { | ||
@@ -77,0 +77,0 @@ blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15637
-44.33%9
-30.77%227
-36.24%