aswi2020vldc-gitlab/templetes/node_modules/public-encrypt/mgf.js @ 0b434236
1 | 3a515b92 | cagy | var createHash = require('create-hash') |
---|---|---|---|
2 | var Buffer = require('safe-buffer').Buffer |
||
3 | |||
4 | module.exports = function (seed, len) { |
||
5 | var t = Buffer.alloc(0) |
||
6 | var i = 0 |
||
7 | var c |
||
8 | while (t.length < len) { |
||
9 | c = i2ops(i++) |
||
10 | t = Buffer.concat([t, createHash('sha1').update(seed).update(c).digest()]) |
||
11 | }
|
||
12 | return t.slice(0, len) |
||
13 | }
|
||
14 | |||
15 | function i2ops (c) { |
||
16 | var out = Buffer.allocUnsafe(4) |
||
17 | out.writeUInt32BE(c, 0) |
||
18 | return out |
||
19 | }
|