import * as crypto from "crypto" ; param { string } algorithm param { Buffer } secret param { Buffer } data returns { Buffer } function hmac ( algorithm , secret , data ) { const hash = crypto . createHmac ( algorithm , secret ) ; hash . update ( data ) ; return hash . digest ( ) ; } param { number } bytes param { string } algorithm param { Buffer } secret param { Buffer } seed returns { Buffer } function pHash ( bytes , algorithm , secret , seed ) { const totalLength = bytes ; const bufs = [ ] ; let Ai = seed ; do { Ai = hmac ( algorithm , secret , Ai ) ; const output = hmac ( algorithm , secret , Buffer . concat ( [ Ai , seed ] ) ) ; bufs . push ( output ) ; bytes -= output . length ; } while ( bytes > 0 ) ; return Buffer . concat ( bufs , totalLength ) ; } export { hmac , pHash } ;