mirror of
https://github.com/emn178/js-sha256.git
synced 2026-08-13 04:51:56 +08:00
Fixed
- incorrect result when first bit is 1 of bytes. Changed - throw error by Error oject. #13 Added - TypeScript interfaces. #12
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## v0.9.0 / 2017-12-18
|
||||||
|
### Fixed
|
||||||
|
- incorrect result when first bit is 1 of bytes.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- throw error by Error oject. #13
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- TypeScript interfaces. #12
|
||||||
|
|
||||||
## v0.8.0 / 2017-11-19
|
## v0.8.0 / 2017-11-19
|
||||||
### Added
|
### Added
|
||||||
- support for web worker.
|
- support for web worker.
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "js-sha256",
|
"name": "js-sha256",
|
||||||
"version": "0.8.0",
|
"version": "0.9.0",
|
||||||
"main": ["src/sha256.js"],
|
"main": ["src/sha256.js"],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"samples",
|
"samples",
|
||||||
|
|||||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+85
-3
@@ -34,6 +34,63 @@ interface Hasher {
|
|||||||
array(): number[];
|
array(): number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Hmac {
|
||||||
|
/**
|
||||||
|
* Computes a Hash-based message authentication code (HMAC) using a secret key
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
(secretKey: string, message: Message): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a hash object using a secret key.
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
*/
|
||||||
|
create(secretKey: string): Hasher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a hash object and hash message using a secret key
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
update(secretKey: string, message: Message): Hasher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in hex string.
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
hex(secretKey: string, message: Message): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in ArrayBuffer.
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
arrayBuffer(secretKey: string, message: Message): ArrayBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in integer array.
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
digest(secretKey: string, message: Message): number[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in integer array.
|
||||||
|
*
|
||||||
|
* @param secretKey The Secret Key
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
array(secretKey: string, message: Message): number[];
|
||||||
|
}
|
||||||
|
|
||||||
interface Hash {
|
interface Hash {
|
||||||
/**
|
/**
|
||||||
* Hash and return hex string.
|
* Hash and return hex string.
|
||||||
@@ -55,12 +112,37 @@ interface Hash {
|
|||||||
update(message: Message): Hasher;
|
update(message: Message): Hasher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes a Hash-based message authentication code (HMAC) using a secret key
|
* Return hash in hex string.
|
||||||
*
|
*
|
||||||
* @param secretKey The Secret Key
|
|
||||||
* @param message The message you want to hash.
|
* @param message The message you want to hash.
|
||||||
*/
|
*/
|
||||||
hmac(secretKey: string, message: Message): string;
|
hex(message: Message): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in ArrayBuffer.
|
||||||
|
*
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
arrayBuffer(message: Message): ArrayBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in integer array.
|
||||||
|
*
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
digest(message: Message): number[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return hash in integer array.
|
||||||
|
*
|
||||||
|
* @param message The message you want to hash.
|
||||||
|
*/
|
||||||
|
array(message: Message): number[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HMAC interface
|
||||||
|
*/
|
||||||
|
hmac: Hmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
export var sha256: Hash;
|
export var sha256: Hash;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "js-sha256",
|
"name": "js-sha256",
|
||||||
"version": "0.8.0",
|
"version": "0.9.0",
|
||||||
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
|
"description": "A simple SHA-256 / SHA-224 hash function for JavaScript supports UTF-8 encoding.",
|
||||||
"main": "src/sha256.js",
|
"main": "src/sha256.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
||||||
*
|
*
|
||||||
* @version 0.8.0
|
* @version 0.9.0
|
||||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* @copyright Chen, Yi-Cyuan 2014-2017
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||||
* @license MIT
|
* @license MIT
|
||||||
@@ -257,7 +257,7 @@
|
|||||||
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
||||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||||
}
|
}
|
||||||
blocks[14] = this.hBytes << 3 | this.bytes >> 29;
|
blocks[14] = this.hBytes << 3 | this.bytes >>> 29;
|
||||||
blocks[15] = this.bytes << 3;
|
blocks[15] = this.bytes << 3;
|
||||||
this.hash();
|
this.hash();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user