Swap-Aggregator-Subgraph/node_modules/asmcrypto.js/dist_es5/pbkdf2/pbkdf2-hmac-sha256.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

15 lines
616 B
JavaScript
Executable File

import { HmacSha256 } from '../hmac/hmac-sha256';
export function Pbkdf2HmacSha256(password, salt, count, length) {
var hmac = new HmacSha256(password);
var result = new Uint8Array(length);
var blocks = Math.ceil(length / hmac.HMAC_SIZE);
for (var i = 1; i <= blocks; ++i) {
var j = (i - 1) * hmac.HMAC_SIZE;
var l = (i < blocks ? 0 : length % hmac.HMAC_SIZE) || hmac.HMAC_SIZE;
hmac.reset().process(salt);
hmac.hash.asm.pbkdf2_generate_block(hmac.hash.pos, hmac.hash.len, i, count, 0);
result.set(hmac.hash.heap.subarray(0, l), j);
}
return result;
}