Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
- TypeScript support.
- ArrayBuffer method.
Deprecated
- Buffer method.
  • Loading branch information
emn178 committed Sep 26, 2016
1 parent bb08d1f commit 97e70fe
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 79 deletions.
120 changes: 66 additions & 54 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,66 @@
# v0.5.4 / 2016-09-12

* Added CommonJS detection.

# v0.5.3 / 2016-09-08

* Added some files to npm package.

# v0.5.2 / 2016-06-06

* Fixed shake output incorrect in the special length.

# v0.5.1 / 2015-10-27

* Update package.json and bower.json.

# v0.5.0 / 2015-09-23

* Support update interface.

# v0.4.1 / 2015-09-18

* Support to output Integer Array.
* Fixed shake output incorrect when it's greater than 1088.

# v0.4.0 / 2015-09-17

* Support to output ArrayBuffer.
* Add shake alogirthms.

# v0.3.1 / 2015-05-22

* Fixed bugs.

# v0.3.0 / 2015-05-21

* Support byte array and ArrayBuffer input.

# v0.2.0 / 2015-04-04

* Implement NIST's May 2014 SHA-3 version.
* Rename original methods to keccak.

# v0.1.2 / 2015-02-27

* Improve performance.

# v0.1.1 / 2015-02-26

* Improve performance.

# v0.1.0 / 2015-02-23

* Initial release
# Change Log

## v0.5.5 / 2016-09-26
### Added
- TypeScript support.
- ArrayBuffer method.
### Deprecated
- Buffer method.

## v0.5.4 / 2016-09-12
### Fixed
- CommonJS detection.

## v0.5.3 / 2016-09-08
### Added
- Some missing files to npm package.

## v0.5.2 / 2016-06-06
### Fixed
- Shake output incorrect in the special length.

## v0.5.1 / 2015-10-27
### Fixed
- Version in package.json and bower.json.

## v0.5.0 / 2015-09-23
### Added
- Hash object with create/update interface.

## v0.4.1 / 2015-09-18
### Added
- Integer array output.
### Fixed
- Shake output incorrect when it's greater than 1088.

## v0.4.0 / 2015-09-17
### Added
- ArrayBuffer output.
- Shake alogirthms.

## v0.3.1 / 2015-05-22
### Fixed
- Some bugs.

## v0.3.0 / 2015-05-21
### Added
- Integer array input.
- ArrayBuffer input.

## v0.2.0 / 2015-04-04
### Added
- NIST's May 2014 SHA-3 version.
### Changed
- Rename original methods to keccak.

## v0.1.2 / 2015-02-27
### Changed
- Improve performance.

## v0.1.1 / 2015-02-26
### Changed
- Improve performance.

## v0.1.0 / 2015-02-23
### Added
- First version implementation.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# js-sha3

[![Build Status](https://travis-ci.org/emn178/js-sha3.svg?branch=master)](https://travis-ci.org/emn178/js-sha3)
[![Coverage Status](https://coveralls.io/repos/emn178/js-sha3/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-sha3?branch=master)
[![Coverage Status](https://coveralls.io/repos/emn178/js-sha3/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-sha3?branch=master)
[![NPM](https://nodei.co/npm/js-sha3.png?stars&downloads)](https://nodei.co/npm/js-sha3/)

A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.

## Notice
Sha3 methods has been renamed to keccak since v0.2.0. It means that sha3 methods of v0.1.x are equal to keccak methods of v0.2.x and later.
* Sha3 methods has been renamed to keccak since v0.2.0. It means that sha3 methods of v0.1.x are equal to keccak methods of v0.2.x and later.
* `buffer` method is deprecated. This maybe confuse with Buffer in node.js. Please use `arrayBuffer` instead.

## Demo
[SHA3-512 Online](http://emn178.github.io/online-tools/sha3_512.html)
Expand All @@ -17,6 +19,8 @@ Sha3 methods has been renamed to keccak since v0.2.0. It means that sha3 methods
[Keccak-384 Online](http://emn178.github.io/online-tools/keccak_384.html)
[Keccak-256 Online](http://emn178.github.io/online-tools/keccak_256.html)
[Keccak-224 Online](http://emn178.github.io/online-tools/keccak_224.html)
[Shake-128 Online](http://emn178.github.io/online-tools/shake_128.html)
[Shake-256 Online](http://emn178.github.io/online-tools/shake_256.html)

## Download
[Compress](https://raw.github.com/emn178/js-sha3/master/build/sha3.min.js)
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-sha3",
"version": "0.5.4",
"version": "0.5.5",
"main": ["src/sha3.js"],
"ignore": [
"samples",
Expand Down
28 changes: 14 additions & 14 deletions build/sha3.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
type Message = string | number[] | ArrayBuffer | Uint8Array;

interface Hasher {
/**
* Update hash
*
* @param message The message you want to hash.
*/
update(message: Message): Hasher;

/**
* Return hash in hex string.
*/
hex(): string;

/**
* Return hash in hex string.
*/
toString(): string;

/**
* Return hash in ArrayBuffer.
*/
arrayBuffer(): ArrayBuffer;

/**
* Return hash in integer array.
*/
digest(): number[];

/**
* Return hash in integer array.
*/
array(): number[];
}

interface Hash {
/**
* Hash and return hex string.
*
* @param message The message you want to hash.
*/
(message: Message): string;

/**
* Create a hash object.
*/
create(): Hasher;

/**
* Create a hash object and hash message.
*
* @param message The message you want to hash.
*/
update(message: Message): Hasher;
}

interface ShakeHash {
/**
* Hash and return hex string.
*
* @param message The message you want to hash.
* @param outputBits The length of output.
*/
(message: Message, outputBits: number): string;

/**
* Create a hash object.
*
* @param outputBits The length of output.
*/
create(outputBits: number): Hasher;

/**
* Create a hash object and hash message.
*
* @param message The message you want to hash.
* @param outputBits The length of output.
*/
update(message: Message, outputBits: number): Hasher;
}

export var sha3_512: Hash;
export var sha3_384: Hash;
export var sha3_256: Hash;
export var sha3_224: Hash;
export var keccak_512: Hash;
export var keccak_384: Hash;
export var keccak_256: Hash;
export var keccak_224: Hash;
export var shake_128: ShakeHash;
export var shake_256: ShakeHash;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "js-sha3",
"version": "0.5.4",
"version": "0.5.5",
"description": "A simple SHA-3 / Keccak / Shake hash function for JavaScript supports UTF-8 encoding.",
"main": "src/sha3.js",
"typings": "index",
"devDependencies": {
"expect.js": "~0.3.1",
"jscoverage": "~0.5.9",
Expand Down
Loading

0 comments on commit 97e70fe

Please sign in to comment.