git ssb

0+

cel / pull-git-remote-helper



Tree: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247

Files: c2f96fca4e0046fd6b5ee048898f8db2c2c1d247 / util.js

593 bytesRaw
1var crypto = require('crypto')
2var pull = require('pull-stream')
3
4exports.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
17exports.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