[Pkg-javascript-commits] [node-sha.js] 14/237: hammer in a piton, incase I fall off this cliff
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:02:51 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-sha.js.
commit 0a211b2b0abda6252f59f6f3892df1411670c72f
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Thu Dec 26 18:54:56 2013 +0700
hammer in a piton, incase I fall off this cliff
---
hash.js | 38 ++++++++++++++------------------------
1 file changed, 14 insertions(+), 24 deletions(-)
diff --git a/hash.js b/hash.js
index 578efe7..2bfbc45 100644
--- a/hash.js
+++ b/hash.js
@@ -20,40 +20,30 @@ Hash.prototype.update = function (data, enc) {
//for encoding/decoding utf8, see here:
//https://github.com/chrisdickinson/bops/blob/master/typedarray/from.js#L36-L57
//https://github.com/chrisdickinson/to-utf8
-
- //for now, assume ascii.
- var start = this._l || 0
- this._len += data.length
- console.log('update', JSON.stringify(data), start, data.length)
var bl = this._block.byteLength
+ //for now, assume ascii.
- if(data.length <= bl - start) {
- u.write(this._x.buffer, data, 'ascii', start, 0, data.length)
- this._l = (this._l || 0) + data.length
- }
- else {
- var from = 0
- var to = (from + bl) - this._l
- while(from < data.length) {
- console.log('OVERFLOW')
- u.write(this._x.buffer, data, 'ascii', this._l % bl, from, to)
- from = to
- to = Math.min(bl - this._l, data.length)
- this._update()
- this._l = 0
- }
+ var l = this._len += data.length
+ var s = this._s = (this._s || 0)
+ var f = 0
+ while(s < l) {
+ var t = Math.min(data.length, f + bl)
+ u.write(this._block.buffer, data, 'ascii', l%bl, f, t)
+ s += (t - f)
+ if(!(s%bl))
+ this._update(this._block.buffer)
}
+
console.log('---WRITTEN---')
- console.log(hexpp(this._x))
+ console.log(hexpp(this._block))
return this
}
Hash.prototype.digest = function (enc) {
- this._final()
+ return u.toHex(this._final())
//reverse byte order, so that the individual bytes are in correct order.
- return u.toHex(this._h.buffer)
-
+// return u.toHex(this._hash.buffer)
}
Hash.prototype._update = function () {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git
More information about the Pkg-javascript-commits
mailing list