Files: b2cf98073f3c52efa61e1a9d9a2a6b4af4944906 / util.js
593 bytesRaw
1 | var crypto = require('crypto') |
2 | var pull = require('pull-stream') |
3 | |
4 | exports.createHash = function (type) { |
5 | var hash = crypto.createHash(type) |
6 | var hasher = pull.through(hash.update.bind(hash)) |
7 | var digest |
8 | hasher.hash = hash |
9 | hasher.digest = hash.digest.bind(hash) |
10 | hasher.readDigest = function (abort, cb) { |
11 | if (digest) cb(true) |
12 | else cb(null, digest = hash.digest()) |
13 | } |
14 | return hasher |
15 | } |
16 | |
17 | exports.createGitObjectHash = function (objectType, objectLength) { |
18 | var hasher = exports.createHash('sha1') |
19 | hasher.hash.update(objectType + ' ' + objectLength + '\0') |
20 | return hasher |
21 | } |
22 |
Built with git-ssb-web