import { HMACDRBG } from "./hmac-drbg" ; import { RandomSource } from "@stablelib/random/source" ; import { benchmark , report } from "@stablelib/benchmark" ; class XKCDSource implements RandomSource { isAvailable = true ; randomBytes ( length ) { const out = new Uint8Array ( length ) ; for ( let i = 0 ; i < length ; i ++ ) { out [ i ] = 4 ; } return out ; } } const drbg = new HMACDRBG ( new XKCDSource ( ) ) ; report ( "HMAC_DRBG" , benchmark ( ( ) => drbg . randomBytes ( 1024 ) , 1024 ) ) ;