You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
414 B
17 lines
414 B
2 years ago
|
import createHash from "../create-hash";
|
||
|
function i2ops(c) {
|
||
|
var out = Buffer.allocUnsafe(4);
|
||
|
out.writeUInt32BE(c, 0);
|
||
|
return out;
|
||
|
}
|
||
|
export default (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);
|
||
|
});
|