kjur / jsrsasign

The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES and JSON Web Signature/Token in pure JavaScript.
https://kjur.github.io/jsrsasign
Other
3.28k stars 645 forks source link

Seeding the PRNG #42

Open sbheinric opened 11 years ago

sbheinric commented 11 years ago

I needed to seed the PRNG with a specific value. After some poking around I found that it can be done like so:

function hex2Array(hex) { var arr = new Array(); for (var i = 0; i < hex.length; i += 2) arr[i/2] = parseInt(hex.substr(i, 2), 16); return arr; }

var seedByteArray = hex2Array(seedHexStr);

//////////////// rng_state = prng_newstate(); rng_state.init(seedByteArray); ///////////////

It might be nice to add these last two lines into a "seed" function of the SecureRandom class in the future

Ruffio commented 7 years ago

@kjur Any chance that this will be implemented?