This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/public-encrypt/mgf.js

20 lines
423 B
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
var createHash = require('create-hash')
var Buffer = require('safe-buffer').Buffer
module.exports = function (seed, len) {
var t = Buffer.alloc(0)
var i = 0
var c
while (t.length < len) {
c = i2ops(i++)
t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()])
}
return t.slice(0, len)
}
function i2ops (c) {
var out = Buffer.allocUnsafe(4)
out.writeUInt32BE(c, 0)
return out
}