first commit
This commit is contained in:
38
build/node_modules/hash-base/README.md
generated
vendored
Normal file
38
build/node_modules/hash-base/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# hash-base
|
||||
|
||||
[](https://www.npmjs.org/package/hash-base)
|
||||
[](https://travis-ci.org/crypto-browserify/hash-base)
|
||||
[](https://david-dm.org/crypto-browserify/hash-base#info=dependencies)
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
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
|
||||
function MyHash () {
|
||||
HashBase.call(64) // in bytes
|
||||
}
|
||||
|
||||
inherti(MyHash, HashBase)
|
||||
|
||||
MyHash.prototype._update = function () {
|
||||
// hashing one block with buffer this._block
|
||||
}
|
||||
|
||||
MyHash.prototype._digest = function () {
|
||||
// create padding and produce result
|
||||
}
|
||||
```
|
||||
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
|
||||
83
build/node_modules/hash-base/index.js
generated
vendored
Normal file
83
build/node_modules/hash-base/index.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
'use strict'
|
||||
var Transform = require('stream').Transform
|
||||
var inherits = require('inherits')
|
||||
|
||||
function HashBase (blockSize) {
|
||||
Transform.call(this)
|
||||
|
||||
this._block = new Buffer(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 {
|
||||
if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding)
|
||||
this.update(chunk)
|
||||
} 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 (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
|
||||
if (this._finalized) throw new Error('Digest already called')
|
||||
if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary')
|
||||
|
||||
// consume data
|
||||
var block = this._block
|
||||
var offset = 0
|
||||
while (this._blockOffset + data.length - offset >= this._blockSize) {
|
||||
for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++]
|
||||
this._update()
|
||||
this._blockOffset = 0
|
||||
}
|
||||
while (offset < data.length) block[this._blockOffset++] = data[offset++]
|
||||
|
||||
// update length
|
||||
for (var j = 0, carry = data.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 (data) {
|
||||
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)
|
||||
return digest
|
||||
}
|
||||
|
||||
HashBase.prototype._digest = function () {
|
||||
throw new Error('_digest is not implemented')
|
||||
}
|
||||
|
||||
module.exports = HashBase
|
||||
66
build/node_modules/hash-base/package.json
generated
vendored
Normal file
66
build/node_modules/hash-base/package.json
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"_from": "hash-base@^2.0.0",
|
||||
"_id": "hash-base@2.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=",
|
||||
"_location": "/hash-base",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "hash-base@^2.0.0",
|
||||
"name": "hash-base",
|
||||
"escapedName": "hash-base",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/ripemd160"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz",
|
||||
"_shasum": "66ea1d856db4e8a5470cadf6fce23ae5244ef2e1",
|
||||
"_spec": "hash-base@^2.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/ripemd160",
|
||||
"author": {
|
||||
"name": "Kirill Fomichev",
|
||||
"email": "fanatid@ya.ru",
|
||||
"url": "https://github.com/fanatid"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-browserify/hash-base/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "abstract base class for hash-streams",
|
||||
"devDependencies": {
|
||||
"nyc": "^6.1.1",
|
||||
"standard": "^6.0.8",
|
||||
"tape": "^4.2.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/crypto-browserify/hash-base",
|
||||
"keywords": [
|
||||
"hash",
|
||||
"stream"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "hash-base",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/crypto-browserify/hash-base.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc node test/*.js",
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "node test/*.js"
|
||||
},
|
||||
"version": "2.0.2"
|
||||
}
|
||||
Reference in New Issue
Block a user