Merge remote-tracking branch 'upstream/main'

This commit is contained in:
2026-08-26 09:31:34 +08:00
parent 9b8c4bfab6
commit 394eb0285d
34137 changed files with 3589424 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/ripemd160
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+109
View File
@@ -0,0 +1,109 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.0.3](https://github.com/browserify/ripemd160/compare/v2.0.2...v2.0.3) - 2025-09-22
### Commits
- [eslint] switch from standard to eslint [`ce1badd`](https://github.com/browserify/ripemd160/commit/ce1baddb99b40436d8253d5f4472ae5432e8ed24)
- [Tests] migrate from travis to GHA [`f0b036e`](https://github.com/browserify/ripemd160/commit/f0b036e204b77075a70a46c2ef457a6f53fc1e6c)
- [meta] use `auto-changelog` [`8f8b834`](https://github.com/browserify/ripemd160/commit/8f8b8340426e276df881296a138a0cbbaa44525a)
- [meta] use `npmignore` [`63eb742`](https://github.com/browserify/ripemd160/commit/63eb742d7dec26c45c4a60f93ace332b8be98179)
- [Tests] add coverage [`52e4349`](https://github.com/browserify/ripemd160/commit/52e43496031e21681d83e55ece0beba982b2cdca)
- Only apps should have lockfiles [`bbbc504`](https://github.com/browserify/ripemd160/commit/bbbc504d455f9692efc3c4be7d613bd57eea50de)
- [meta] add missing `engines.node` [`0dd76a0`](https://github.com/browserify/ripemd160/commit/0dd76a0c05658b23b3d10886f18c561901d57ce9)
- [Deps] update `hash-base`, `inherits` [`dcd9920`](https://github.com/browserify/ripemd160/commit/dcd99208dd3cab39b0ef5ee63fe604d278e03048)
- [meta] fix npmrc settings for auto-changelog [`329f18c`](https://github.com/browserify/ripemd160/commit/329f18cae8acee98f03d765a34f2f84afe6e1791)
- [Dev Deps] update `tape` [`8be8aba`](https://github.com/browserify/ripemd160/commit/8be8abaaf2dcf494abe10fa38d2a3db91f85de3d)
- [Dev Deps] add missing peer dep [`ac4ddb3`](https://github.com/browserify/ripemd160/commit/ac4ddb3a57b8625d69b5ca37b1b994b4dde1affe)
## [v2.0.2](https://github.com/browserify/ripemd160/compare/2.0.1...v2.0.2) - 2018-04-19
### Merged
- Don't use the deprecated Buffer() constructor [`#20`](https://github.com/browserify/ripemd160/pull/20)
- code optimization (30%) [`#14`](https://github.com/browserify/ripemd160/pull/14)
- Not a markdown file [`#18`](https://github.com/browserify/ripemd160/pull/18)
### Commits
- Explicitly require 'buffer' [`651ae24`](https://github.com/browserify/ripemd160/commit/651ae24445a9486fdea1707e45309b28fee35cfa)
<!-- auto-changelog-above -->
2.0.1 / 2016-06-22
------------------
- added LICENSE file.
2.0.0 / 2016-04-11
------------------
- rewritten, license change BSD-3 to MIT. [#13][#13]
- stream support [#13][#13]
1.0.1 / 2015-05-05
------------------
- standard formatting
1.0.0 / 2015-01-14
------------------
- updated dev deps
- added more test fixtures
- updated readme with usage, testing, etc
- moved from https://github.com/cryptocoinjs/ripemd160 to https://github.com/crypto-browserify/ripemd160
0.2.1 / 2014-12-31
------------------
- made license clear in `package.json`
- deleted `Makefile`, moved targets to `package.json`
- removed `terst` for `assert`
0.2.0 / 2014-03-09
------------------
* removed bower.json and component.json
* changed 4 spacing to 2
* returns `Buffer` type now, input must be Array, Uint8Array, Buffer, or string
* remove deps: `convert-hex` and `convert-string`
0.1.0 / 2013-11-20
------------------
* changed package name
* removed AMD support
0.0.2 / 2013-11-06
------------------
* fixed component.json file
0.0.1 / 2013-11-03
------------------
* initial release
<!--- add streams support, unroll loops [enhancement] -->
[#13]: https://github.com/crypto-browserify/ripemd160/pull/13
<!--- Update all dependencies 🌴 [greenkeeper] -->
[#12]: https://github.com/crypto-browserify/ripemd160/pull/12
<!--- little optimizations [enhancement] -->
[#11]: https://github.com/crypto-browserify/ripemd160/pull/11
<!--- Added LICENSE file to repo -->
[#10]: https://github.com/crypto-browserify/ripemd160/pull/10
<!--- Add LICENCE file -->
[#9]: https://github.com/crypto-browserify/ripemd160/pull/9
<!--- Support streaming [enhancement] -->
[#8]: https://github.com/crypto-browserify/ripemd160/issues/8
<!--- Unroll loops [enhancement] -->
[#7]: https://github.com/crypto-browserify/ripemd160/pull/7
<!--- Use SPDX-standard license naming -->
[#6]: https://github.com/crypto-browserify/ripemd160/pull/6
<!--- License -->
[#5]: https://github.com/crypto-browserify/ripemd160/issues/5
<!--- Add BSD license to package.json -->
[#4]: https://github.com/crypto-browserify/ripemd160/pull/4
<!--- Indicate byte array inputs are supported too -->
[#3]: https://github.com/crypto-browserify/ripemd160/pull/3
<!--- Node-specific implementation -->
[#2]: https://github.com/crypto-browserify/ripemd160/pull/2
<!--- Incorrect name of convert-string dependency in bower.json -->
[#1]: https://github.com/crypto-browserify/ripemd160/pull/1
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 crypto-browserify
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+27
View File
@@ -0,0 +1,27 @@
# ripemd160
[![NPM Package](https://img.shields.io/npm/v/ripemd160.svg?style=flat-square)](https://www.npmjs.org/package/ripemd160)
[![Build Status](https://img.shields.io/travis/crypto-browserify/ripemd160.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/ripemd160)
[![Dependency status](https://img.shields.io/david/crypto-browserify/ripemd160.svg?style=flat-square)](https://david-dm.org/crypto-browserify/ripemd160#info=dependencies)
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
Node style `ripemd160` on pure JavaScript.
## Example
```js
var RIPEMD160 = require('ripemd160')
console.log(new RIPEMD160().update('42').digest('hex'))
// => 0df020ba32aa9b8b904471ff582ce6b579bf8bc8
var ripemd160stream = new RIPEMD160()
ripemd160stream.end('42')
console.log(ripemd160stream.read().toString('hex'))
// => 0df020ba32aa9b8b904471ff582ce6b579bf8bc8
```
## LICENSE
MIT
+167
View File
@@ -0,0 +1,167 @@
'use strict';
var Buffer = require('buffer').Buffer;
var inherits = require('inherits');
var HashBase = require('hash-base');
var ARRAY16 = new Array(16);
var zl = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
];
var zr = [
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
];
var sl = [
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
];
var sr = [
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
];
var hl = [0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e];
var hr = [0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000];
function rotl(x, n) {
return (x << n) | (x >>> (32 - n));
}
function fn1(a, b, c, d, e, m, k, s) {
return (rotl((a + (b ^ c ^ d) + m + k) | 0, s) + e) | 0;
}
function fn2(a, b, c, d, e, m, k, s) {
return (rotl((a + ((b & c) | (~b & d)) + m + k) | 0, s) + e) | 0;
}
function fn3(a, b, c, d, e, m, k, s) {
return (rotl((a + ((b | ~c) ^ d) + m + k) | 0, s) + e) | 0;
}
function fn4(a, b, c, d, e, m, k, s) {
return (rotl((a + ((b & d) | (c & ~d)) + m + k) | 0, s) + e) | 0;
}
function fn5(a, b, c, d, e, m, k, s) {
return (rotl((a + (b ^ (c | ~d)) + m + k) | 0, s) + e) | 0;
}
function RIPEMD160() {
HashBase.call(this, 64);
// state
this._a = 0x67452301;
this._b = 0xefcdab89;
this._c = 0x98badcfe;
this._d = 0x10325476;
this._e = 0xc3d2e1f0;
}
inherits(RIPEMD160, HashBase);
RIPEMD160.prototype._update = function () {
var words = ARRAY16;
for (var j = 0; j < 16; ++j) {
words[j] = this._block.readInt32LE(j * 4);
}
var al = this._a | 0;
var bl = this._b | 0;
var cl = this._c | 0;
var dl = this._d | 0;
var el = this._e | 0;
var ar = this._a | 0;
var br = this._b | 0;
var cr = this._c | 0;
var dr = this._d | 0;
var er = this._e | 0;
// computation
for (var i = 0; i < 80; i += 1) {
var tl;
var tr;
if (i < 16) {
tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]);
tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]);
} else if (i < 32) {
tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]);
tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]);
} else if (i < 48) {
tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]);
tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]);
} else if (i < 64) {
tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]);
tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]);
} else { // if (i<80) {
tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]);
tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]);
}
al = el;
el = dl;
dl = rotl(cl, 10);
cl = bl;
bl = tl;
ar = er;
er = dr;
dr = rotl(cr, 10);
cr = br;
br = tr;
}
// update state
var t = (this._b + cl + dr) | 0;
this._b = (this._c + dl + er) | 0;
this._c = (this._d + el + ar) | 0;
this._d = (this._e + al + br) | 0;
this._e = (this._a + bl + cr) | 0;
this._a = t;
};
RIPEMD160.prototype._digest = function () {
// create padding and handle blocks
this._block[this._blockOffset] = 0x80;
this._blockOffset += 1;
if (this._blockOffset > 56) {
this._block.fill(0, this._blockOffset, 64);
this._update();
this._blockOffset = 0;
}
this._block.fill(0, this._blockOffset, 56);
this._block.writeUInt32LE(this._length[0], 56);
this._block.writeUInt32LE(this._length[1], 60);
this._update();
// produce result
var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20); // eslint-disable-line no-buffer-constructor
buffer.writeInt32LE(this._a, 0);
buffer.writeInt32LE(this._b, 4);
buffer.writeInt32LE(this._c, 8);
buffer.writeInt32LE(this._d, 12);
buffer.writeInt32LE(this._e, 16);
return buffer;
};
module.exports = RIPEMD160;
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/hash-base
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+166
View File
@@ -0,0 +1,166 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.1.2](https://github.com/browserify/hash-base/compare/v3.1.1...v3.1.2) - 2025-09-22
### Commits
- [fix] package already works in node 0.8 [`1c19201`](https://github.com/browserify/hash-base/commit/1c1920112ef4baa65085b08ada90b4d0a83b69f2)
- [Dev Deps] add missing peer dep [`7ac34b6`](https://github.com/browserify/hash-base/commit/7ac34b6011fb02b7a8261ee35f01fe8828218dda)
## [v3.1.1](https://github.com/browserify/hash-base/compare/v3.1.0...v3.1.1) - 2025-09-22
### Commits
- [eslint] switch to eslint [`d63bf3b`](https://github.com/browserify/hash-base/commit/d63bf3b65c911e0de091918b7d331c6cf413567e)
- [meta] add `auto-changelog` [`b2c7408`](https://github.com/browserify/hash-base/commit/b2c74084f744d090a1c59d2f8326a639409281f2)
- [Tests] avoid tape-mutating beforeEach nonsense [`bb1f9b6`](https://github.com/browserify/hash-base/commit/bb1f9b6492acd97fd02acca575dcb334888b6fbb)
- [Tests] avoid tape-mutating beforeEach nonsense [`ae228cd`](https://github.com/browserify/hash-base/commit/ae228cd0e9421fcca4c7e9e41b5451fa7ad74c73)
- [readme] clean up formatting [`fd5cb3d`](https://github.com/browserify/hash-base/commit/fd5cb3d73a9be7617b6af647dd775ede7f5dab24)
- [readme] clean up formatting [`a13ed61`](https://github.com/browserify/hash-base/commit/a13ed61331879e342435e71569a49061fdf1889c)
- [Tests] migrate from travis to GHA [`9e2c04c`](https://github.com/browserify/hash-base/commit/9e2c04c435c25363fbe1f1fea8b32390f3f623b7)
- [Tests] migrate from travis to GHA [`31766d4`](https://github.com/browserify/hash-base/commit/31766d413a21e534c96e6e562174f74b3d0368ca)
- [Fix] return valid values on multi-byte-wide TypedArray input [`1af18ee`](https://github.com/browserify/hash-base/commit/1af18ee40d747bc177fba2cb89b4e937e3bd0724)
- [Refactor] use `to-buffer` [`41d738b`](https://github.com/browserify/hash-base/commit/41d738bca2c5fa97c09bed9cdc7b2f3d8f1f9958)
- [Dev Deps] update `tape`, downgrade `nyc`, clean up scripts [`13d373c`](https://github.com/browserify/hash-base/commit/13d373c1b06ed0a20db0fe158def49a7abf6a85b)
- [Dev Deps] update `tape`, downgrade `nyc`, clean up scripts [`84f4fab`](https://github.com/browserify/hash-base/commit/84f4fab691c35591f44b1781311de10fc6f76b16)
- [meta] use `npmignore` [`ecdd9a3`](https://github.com/browserify/hash-base/commit/ecdd9a312e26f81d6a84256d8bcdbf4427f84490)
- Merge tag 'v3.0.5' [`d59c766`](https://github.com/browserify/hash-base/commit/d59c766986d962868457d05299fe111323dedd6f)
- Only apps should have lockfiles [`de3ce83`](https://github.com/browserify/hash-base/commit/de3ce831c7f61a2ca3448f639d7b8ebe6b7b27ab)
- Only apps should have lockfiles [`05b7504`](https://github.com/browserify/hash-base/commit/05b7504d4038fdf380e5c3227ee0719df12f5bda)
- [Deps] update `inherits`, `safe-buffer` [`2b8687d`](https://github.com/browserify/hash-base/commit/2b8687d89f8e9de6c21bc277b147e76507ba74a6)
- [Deps] update `safe-buffer`; downgrade `readable-stream` [`523da5d`](https://github.com/browserify/hash-base/commit/523da5dbfcef879a5c6967978cd4d39946f20c5a)
- [Tests] clean up linting [`4274b7c`](https://github.com/browserify/hash-base/commit/4274b7cc9608712652e56091efcf5c66151be418)
- [Tests] in node 0.10, Buffer `.fill` returns `undefined` [`0fdfd67`](https://github.com/browserify/hash-base/commit/0fdfd676fc51987e5d93f17858cc0f740b56b6af)
- [Tests] in node 0.10, Buffer `.fill` returns `undefined` [`5d1f911`](https://github.com/browserify/hash-base/commit/5d1f91153a0c8365e970e0f9a4fde2fd901bb446)
- [Fix] restore `engines.node` from 3.0.0 [`8cbfd12`](https://github.com/browserify/hash-base/commit/8cbfd123b307d51b6588718baa2c343dddf13fa4)
- [Fix] restore `engines.node` from 3.0.0 [`b99d8a1`](https://github.com/browserify/hash-base/commit/b99d8a1ce428683c93ac005ea01e48f77ce005db)
- [Tests] use `safe-buffer` in tests, too [`84bdfe9`](https://github.com/browserify/hash-base/commit/84bdfe944f46edbcaffed7b48567faf460f13bb8)
- [Tests] use `safe-buffer` in tests, too [`9182f82`](https://github.com/browserify/hash-base/commit/9182f823b7f365189116a4582fa906f8fb008ab6)
## [v3.1.0](https://github.com/browserify/hash-base/compare/v3.0.5...v3.1.0) - 2020-05-01
### Merged
- Update deps, add readable-stream [`#14`](https://github.com/browserify/hash-base/pull/14)
## [v3.0.5](https://github.com/browserify/hash-base/compare/v3.0.4...v3.0.5) - 2024-11-23
### Commits
- [Tests] avoid tape-mutating beforeEach nonsense [`ae228cd`](https://github.com/browserify/hash-base/commit/ae228cd0e9421fcca4c7e9e41b5451fa7ad74c73)
- [readme] clean up formatting [`a13ed61`](https://github.com/browserify/hash-base/commit/a13ed61331879e342435e71569a49061fdf1889c)
- [Tests] migrate from travis to GHA [`31766d4`](https://github.com/browserify/hash-base/commit/31766d413a21e534c96e6e562174f74b3d0368ca)
- [Fix] return valid values on multi-byte-wide TypedArray input [`1af18ee`](https://github.com/browserify/hash-base/commit/1af18ee40d747bc177fba2cb89b4e937e3bd0724)
- [Dev Deps] update `tape`, downgrade `nyc`, clean up scripts [`13d373c`](https://github.com/browserify/hash-base/commit/13d373c1b06ed0a20db0fe158def49a7abf6a85b)
- Only apps should have lockfiles [`de3ce83`](https://github.com/browserify/hash-base/commit/de3ce831c7f61a2ca3448f639d7b8ebe6b7b27ab)
- [Deps] update `inherits`, `safe-buffer` [`2b8687d`](https://github.com/browserify/hash-base/commit/2b8687d89f8e9de6c21bc277b147e76507ba74a6)
- [Tests] clean up linting [`4274b7c`](https://github.com/browserify/hash-base/commit/4274b7cc9608712652e56091efcf5c66151be418)
- [Tests] in node 0.10, Buffer `.fill` returns `undefined` [`5d1f911`](https://github.com/browserify/hash-base/commit/5d1f91153a0c8365e970e0f9a4fde2fd901bb446)
- [Fix] restore `engines.node` from 3.0.0 [`8cbfd12`](https://github.com/browserify/hash-base/commit/8cbfd123b307d51b6588718baa2c343dddf13fa4)
- [Tests] use `safe-buffer` in tests, too [`9182f82`](https://github.com/browserify/hash-base/commit/9182f823b7f365189116a4582fa906f8fb008ab6)
## [v3.0.4](https://github.com/browserify/hash-base/compare/v3.0.3...v3.0.4) - 2017-05-24
### Merged
- use safe-buffer [`#12`](https://github.com/browserify/hash-base/pull/12)
- Only Node v4 or greater [Buffer only] [`#11`](https://github.com/browserify/hash-base/pull/11)
- Reset state after #_digest [`#10`](https://github.com/browserify/hash-base/pull/10)
### Commits
- Improve tests [`b20d350`](https://github.com/browserify/hash-base/commit/b20d3509f1d3b79f68bd9cd330938ca6472b9aa5)
- Only Node v4 or greater [`8e24ac9`](https://github.com/browserify/hash-base/commit/8e24ac9258a1c9294960ee24820eed7494c38e10)
- Real example in README [`71fc5bb`](https://github.com/browserify/hash-base/commit/71fc5bb4ac98a837bc68a34b58aa668e88031a33)
- Typecheck as function [`867095d`](https://github.com/browserify/hash-base/commit/867095d2d7d369d1c24a44d64bdf403ecb1dd653)
- Reset state after HashBase#_digest [`1a4298c`](https://github.com/browserify/hash-base/commit/1a4298c9401597c5e632b29a653ca88d965ae2b2)
- Update devdependencies [`3b46138`](https://github.com/browserify/hash-base/commit/3b46138ad6779cc7f50b4ab3a4a93c7c84cf9dda)
- Add node7 to travis [`3d29655`](https://github.com/browserify/hash-base/commit/3d29655b7add9008e88f76f4acb5bfe77df7833e)
- Fix example in README [`89cdcd8`](https://github.com/browserify/hash-base/commit/89cdcd885a0473b9b6109d6bf285baba8cbeea3f)
## [v3.0.3](https://github.com/browserify/hash-base/compare/v3.0.2...v3.0.3) - 2016-08-28
### Commits
- Add LICENSE file [`3d998aa`](https://github.com/browserify/hash-base/commit/3d998aaa4e6fbacc86b1b0f28b6fb7a4e4398998)
## [v3.0.2](https://github.com/browserify/hash-base/compare/v3.0.1...v3.0.2) - 2016-08-25
### Commits
- Remove extra check [`bd13db2`](https://github.com/browserify/hash-base/commit/bd13db2156ce1fa56ddfc7931ef034aebf693903)
## [v3.0.1](https://github.com/browserify/hash-base/compare/v3.0.0...v3.0.1) - 2016-08-09
### Merged
- Fix ._flush [`#7`](https://github.com/browserify/hash-base/pull/7)
- Update nyc to version 7.0.0 🚀 [`#6`](https://github.com/browserify/hash-base/pull/6)
### Commits
- Change ._digest to .digest in ._flush [`fdad9ad`](https://github.com/browserify/hash-base/commit/fdad9ad23f9a43f388123667e7ba917100e4fe3a)
- Fix typo in README.md [`13264ec`](https://github.com/browserify/hash-base/commit/13264ec7adf25d68c3ff6a8a9a26f7e57282080f)
- chore(package): update nyc to version 7.0.0 [`2a24e6a`](https://github.com/browserify/hash-base/commit/2a24e6a664bdd693dac080c81a903fb7548a89e4)
## [v3.0.0](https://github.com/browserify/hash-base/compare/v2.0.2...v3.0.0) - 2016-05-04
### Merged
- utf8 as default encoding [`#4`](https://github.com/browserify/hash-base/pull/4)
- Update standard to version 7.0.0 🚀 [`#5`](https://github.com/browserify/hash-base/pull/5)
### Commits
- chore(package): update standard to version 7.0.0 [`0720515`](https://github.com/browserify/hash-base/commit/0720515b0fa865bdbf772ea07a84c13e6f4db717)
## [v2.0.2](https://github.com/browserify/hash-base/compare/v2.0.1...v2.0.2) - 2016-04-17
### Commits
- Add type checking in .update [`96acf4a`](https://github.com/browserify/hash-base/commit/96acf4a5650fceb9dbaaba9873805a5c9d71eb88)
- Normalize encoding in tests (utf-8 to utf8) [`0bb7c88`](https://github.com/browserify/hash-base/commit/0bb7c8871b177230c83ef27523812590a22ad6b4)
## [v2.0.1](https://github.com/browserify/hash-base/compare/v2.0.0...v2.0.1) - 2016-04-14
### Commits
- Use this._block as local variable [`aa8bab9`](https://github.com/browserify/hash-base/commit/aa8bab94e5d2a905c1abd913684fc00ae6db7a69)
- Change Math.floor to |0 [`24f7bb5`](https://github.com/browserify/hash-base/commit/24f7bb573e4b9d2d3a8851fa72ed446a5df05960)
## [v2.0.0](https://github.com/browserify/hash-base/compare/v1.0.2...v2.0.0) - 2016-04-07
### Fixed
- (Closes #3) remove DEFAULT_ENCODING [`#3`](https://github.com/browserify/hash-base/issues/3)
### Commits
- Add blocks handling [`0c8fb67`](https://github.com/browserify/hash-base/commit/0c8fb676e7d15af1fb7d441a7b9d783c17da5d08)
- (#1) rename _initialized to _finalized [`ea3c00f`](https://github.com/browserify/hash-base/commit/ea3c00fdf768f68313e07f1d93652316f94d9de9)
- Fix code style [`964daa5`](https://github.com/browserify/hash-base/commit/964daa56acf87439b229ee4582cc29f4b6f3a722)
- Rename initialised_ to _initialised [`6e458c6`](https://github.com/browserify/hash-base/commit/6e458c69f9cf124758f68a01a8232fc7c3269945)
## [v1.0.2](https://github.com/browserify/hash-base/compare/v1.0.1...v1.0.2) - 2016-04-04
### Commits
- Update should return hash instance [`59fef2b`](https://github.com/browserify/hash-base/commit/59fef2bc3b417aac5563022bcc928d1ae8161ee9)
## [v1.0.1](https://github.com/browserify/hash-base/compare/v1.0.0...v1.0.1) - 2016-04-04
### Commits
- Throw error on second call digest [`f0b4caf`](https://github.com/browserify/hash-base/commit/f0b4cafb0a87e8bd3c22a6a3b31e323926dc4e63)
- Update README.md [`6ca4555`](https://github.com/browserify/hash-base/commit/6ca4555d3be194f31725ebf21569d759e0bb9b74)
## v1.0.0 - 2016-04-03
### Commits
- Initial commit [`e315bd2`](https://github.com/browserify/hash-base/commit/e315bd2c5c9e98ecac9a45bb5af1c38d87c3bc47)
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Kirill Fomichev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+48
View File
@@ -0,0 +1,48 @@
# hash-base
[![npm Package](https://img.shields.io/npm/v/hash-base.svg?style=flat-square)](https://www.npmjs.org/package/hash-base)
[![Build Status](https://img.shields.io/travis/crypto-browserify/hash-base.svg?branch=master&style=flat-square)](https://travis-ci.org/crypto-browserify/hash-base)
[![Dependency status](https://img.shields.io/david/crypto-browserify/hash-base.svg?style=flat-square)](https://david-dm.org/crypto-browserify/hash-base#info=dependencies)
Abstract base class to inherit from if you want to create streams implementing the same API as node crypto [Hash][1] (for [Cipher][2] / [Decipher][3] check [crypto-browserify/cipher-base][4]).
## Example
```js
const HashBase = require('hash-base');
const inherits = require('inherits');
// our hash function is XOR sum of all bytes
function MyHash () {
HashBase.call(this, 1); // in bytes
this._sum = 0x00;
};
inherits(MyHash, HashBase)
MyHash.prototype._update = function () {
for (let i = 0; i < this._block.length; ++i) {
this._sum ^= this._block[i];
}
};
MyHash.prototype._digest = function () {
return this._sum;
};
const data = Buffer.from([0x00, 0x42, 0x01]);
const hash = new MyHash().update(data).digest();
console.log(hash); // => 67
```
You also can check [source code](index.js) or [crypto-browserify/md5.js][5]
## LICENSE
MIT
[1]: https://nodejs.org/api/crypto.html#crypto_class_hash
[2]: https://nodejs.org/api/crypto.html#crypto_class_cipher
[3]: https://nodejs.org/api/crypto.html#crypto_class_decipher
[4]: https://github.com/crypto-browserify/cipher-base
[5]: https://github.com/crypto-browserify/md5.js
+109
View File
@@ -0,0 +1,109 @@
'use strict';
var Buffer = require('safe-buffer').Buffer;
var toBuffer = require('./to-buffer');
var Transform = require('readable-stream').Transform;
var inherits = require('inherits');
function HashBase(blockSize) {
Transform.call(this);
this._block = Buffer.allocUnsafe(blockSize);
this._blockSize = blockSize;
this._blockOffset = 0;
this._length = [0, 0, 0, 0];
this._finalized = false;
}
inherits(HashBase, Transform);
HashBase.prototype._transform = function (chunk, encoding, callback) {
var error = null;
try {
this.update(chunk, encoding);
} catch (err) {
error = err;
}
callback(error);
};
HashBase.prototype._flush = function (callback) {
var error = null;
try {
this.push(this.digest());
} catch (err) {
error = err;
}
callback(error);
};
HashBase.prototype.update = function (data, encoding) {
if (this._finalized) {
throw new Error('Digest already called');
}
var dataBuffer = toBuffer(data, encoding); // asserts correct input type
// consume data
var block = this._block;
var offset = 0;
while (this._blockOffset + dataBuffer.length - offset >= this._blockSize) {
for (var i = this._blockOffset; i < this._blockSize;) {
block[i] = dataBuffer[offset];
i += 1;
offset += 1;
}
this._update();
this._blockOffset = 0;
}
while (offset < dataBuffer.length) {
block[this._blockOffset] = dataBuffer[offset];
this._blockOffset += 1;
offset += 1;
}
// update length
for (var j = 0, carry = dataBuffer.length * 8; carry > 0; ++j) {
this._length[j] += carry;
carry = (this._length[j] / 0x0100000000) | 0;
if (carry > 0) {
this._length[j] -= 0x0100000000 * carry;
}
}
return this;
};
HashBase.prototype._update = function () {
throw new Error('_update is not implemented');
};
HashBase.prototype.digest = function (encoding) {
if (this._finalized) {
throw new Error('Digest already called');
}
this._finalized = true;
var digest = this._digest();
if (encoding !== undefined) {
digest = digest.toString(encoding);
}
// reset state
this._block.fill(0);
this._blockOffset = 0;
for (var i = 0; i < 4; ++i) {
this._length[i] = 0;
}
return digest;
};
HashBase.prototype._digest = function () {
throw new Error('_digest is not implemented');
};
module.exports = HashBase;
+64
View File
@@ -0,0 +1,64 @@
{
"name": "hash-base",
"version": "3.1.2",
"description": "abstract base class for hash-streams",
"keywords": [
"hash",
"stream"
],
"homepage": "https://github.com/crypto-browserify/hash-base",
"bugs": {
"url": "https://github.com/crypto-browserify/hash-base/issues"
},
"license": "MIT",
"author": "Kirill Fomichev <fanatid@ya.ru> (https://github.com/fanatid)",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/crypto-browserify/hash-base.git"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "nyc tape \"test/**/*.js\"",
"posttest": "npx npm@\">=10.2\" audit --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"dependencies": {
"inherits": "^2.0.4",
"readable-stream": "^2.3.8",
"safe-buffer": "^5.2.1",
"to-buffer": "^1.2.1"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.2.0",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"eslint": "=8.8.0",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"tape": "^5.9.0"
},
"engines": {
"node": ">= 0.8"
},
"publishConfig": {
"ignore": [
".github/workflows",
".eslintrc",
".nycrc",
"test"
]
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
}
}
+20
View File
@@ -0,0 +1,20 @@
'use strict';
var Buffer = require('safe-buffer').Buffer;
var toBuffer = require('to-buffer');
var useUint8Array = typeof Uint8Array !== 'undefined';
var useArrayBuffer = useUint8Array && typeof ArrayBuffer !== 'undefined';
var isView = useArrayBuffer && ArrayBuffer.isView;
module.exports = function (thing, encoding) {
if (
typeof thing === 'string'
|| Buffer.isBuffer(thing)
|| (useUint8Array && thing instanceof Uint8Array)
|| (isView && isView(thing))
) {
return toBuffer(thing, encoding);
}
throw new TypeError('The "data" argument must be a string, a Buffer, a Uint8Array, or a DataView');
};
+64
View File
@@ -0,0 +1,64 @@
{
"name": "ripemd160",
"version": "2.0.3",
"description": "Compute ripemd160 of bytes or strings.",
"keywords": [
"string",
"strings",
"ripemd160",
"ripe160",
"bitcoin",
"bytes",
"cryptography"
],
"license": "MIT",
"main": "./index",
"repository": {
"url": "https://github.com/crypto-browserify/ripemd160",
"type": "git"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"test": "npm run tests-only",
"tests-only": "nyc tape \"test/**/*.js\"",
"posttest": "npx npm@\">= 10.2\" audit --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"dependencies": {
"hash-base": "^3.1.2",
"inherits": "^2.0.4"
},
"devDependencies": {
"@ljharb/eslint-config": "^21.2.0",
"auto-changelog": "^2.5.0",
"encoding": "^0.1.13",
"eslint": "=8.8.0",
"hash-test-vectors": "^1.3.2",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"tape": "^5.9.0"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true,
"startingVersion": "2.0.2"
},
"publishConfig": {
"ignore": [
".github/workflows",
".eslintrc",
".nycrc",
"test"
]
},
"engines": {
"node": ">= 0.8"
}
}