2 Commits
Author SHA1 Message Date
Yi-Cyuan Chen 65b3898c4e Fixed
- incorrect result when first bit is 1 of bytes.

Changed
- prevent webpack to require dependencies.
2017-12-21 20:13:31 +08:00
Yi-Cyuan Chen 4ee5af05d3 Fixed incorrect result when file size >= 512M. 2017-10-31 20:20:45 +08:00
11 changed files with 1842 additions and 24 deletions
+2 -2
View File
@@ -1,3 +1,3 @@
/node_modules/
/covreporter/
/my_test/
/coverage/
/.nyc_output/
+8
View File
@@ -0,0 +1,8 @@
/node_modules/
/coverage/
/.nyc_output/
/tests/
.covignore
.travis.yml
.npmignore
bower.json
+3 -5
View File
@@ -1,12 +1,10 @@
language: node_js
node_js:
- "0.12.15"
- "4.5"
- "6.5.0"
- "6.11.4"
- "8.6.0"
before_install:
- npm install coveralls
- npm install mocha-lcov-reporter
script: npm run-script coveralls
after_success: npm run coveralls
branches:
only:
- master
+11
View File
@@ -1,5 +1,16 @@
# Change Log
## v0.6.0 / 2017-12-21
### Fixed
- incorrect result when first bit is 1 of bytes.
### Changed
- prevent webpack to require dependencies.
## v0.5.0 / 2017-10-31
### Fixed
- incorrect result when file size >= 512M.
## v0.4.1 / 2016-12-30
### Fixed
- ArrayBuffer dosen't work in Webpack.
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright 2014-2016 Chen, Yi-Cyuan
Copyright 2014-2017 Chen, Yi-Cyuan
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "js-sha1",
"version": "0.4.1",
"version": "0.6.0",
"main": ["src/sha1.js"],
"ignore": [
"samples",
+3 -3
View File
File diff suppressed because one or more lines are too long
+1784
View File
File diff suppressed because it is too large Load Diff
+12 -7
View File
@@ -1,20 +1,20 @@
{
"name": "js-sha1",
"version": "0.4.1",
"version": "0.6.0",
"description": "A simple SHA1 hash function for JavaScript supports UTF-8 encoding.",
"main": "src/sha1.js",
"devDependencies": {
"expect.js": "~0.3.1",
"jscoverage": "~0.5.9",
"mocha": "~2.3.4",
"nyc": "^11.3.0",
"requirejs": "^2.1.22",
"uglifyjs": "~2.4.10"
"uglify-js": "^3.1.9"
},
"scripts": {
"test": "mocha tests/node-test.js -r jscoverage",
"report": "mocha tests/node-test.js -r jscoverage --covout=html",
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls",
"build": "uglifyjs src/sha1.js --compress --mangle --comments --output build/sha1.min.js"
"test": "nyc mocha tests/node-test.js",
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"build": "uglifyjs src/sha1.js -c -m eval --comments -o build/sha1.min.js"
},
"repository": {
"type": "git",
@@ -32,5 +32,10 @@
"homepage": "https://github.com/emn178/js-sha1",
"bugs": {
"url": "https://github.com/emn178/js-sha1/issues"
},
"nyc": {
"exclude": [
"tests"
]
}
}
+10 -5
View File
@@ -1,9 +1,9 @@
/*
* [js-sha1]{@link https://github.com/emn178/js-sha1}
*
* @version 0.4.1
* @version 0.6.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2016
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
*/
/*jslint bitwise: true */
@@ -49,8 +49,8 @@
};
var nodeWrap = function (method) {
var crypto = require('crypto');
var Buffer = require('buffer').Buffer;
var crypto = eval("require('crypto')");
var Buffer = eval("require('buffer').Buffer");
var nodeMethod = function (message) {
if (typeof message === 'string') {
return crypto.createHash('sha1').update(message, 'utf8').digest('hex');
@@ -81,7 +81,7 @@
this.h3 = 0x10325476;
this.h4 = 0xC3D2E1F0;
this.block = this.start = this.bytes = 0;
this.block = this.start = this.bytes = this.hBytes = 0;
this.finalized = this.hashed = false;
this.first = true;
}
@@ -143,6 +143,10 @@
this.start = i;
}
}
if (this.bytes > 4294967295) {
this.hBytes += this.bytes / 4294967296 << 0;
this.bytes = this.bytes % 4294967296;
}
return this;
};
@@ -165,6 +169,7 @@
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
blocks[15] = this.bytes << 3;
this.hash();
};
+7
View File
@@ -175,5 +175,12 @@
}
});
});
context('when large size', function () {
var hash = sha1.create();
hash.bytes = 4294967295;
hash.update('any');
expect(hash.hBytes).to.be(1);
});
});
})(sha1);