From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- node_modules/hash-base/README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'node_modules/hash-base/README.md') diff --git a/node_modules/hash-base/README.md b/node_modules/hash-base/README.md index 2fa8f1d23..83ae2edcc 100644 --- a/node_modules/hash-base/README.md +++ b/node_modules/hash-base/README.md @@ -11,19 +11,29 @@ Abstract base class to inherit from if you want to create streams implementing t ## Example ```js +const HashBase = require('hash-base') +const inherits = require('inherits') + +// our hash function is XOR sum of all bytes function MyHash () { - HashBase.call(64) // in bytes + HashBase.call(this, 1) // in bytes + + this._sum = 0x00 } -inherti(MyHash, HashBase) +inherits(MyHash, HashBase) MyHash.prototype._update = function () { - // hashing one block with buffer this._block + for (let i = 0; i < this._block.length; ++i) this._sum ^= this._block[i] } MyHash.prototype._digest = function () { - // create padding and produce result + 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] -- cgit v1.2.3