git ssb

0+

cel / pull-git-remote-helper



Tree: 7bc216a78caca4f4c7f04f98603edaa3617bb669

Files: 7bc216a78caca4f4c7f04f98603edaa3617bb669 / lib / 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