How do you generate cryptographically secure floats in Javascript?
This should be a plug-in for Math.random
, with range (0, 1), but cryptographically secure. Example usage
cryptoFloat.random();
0.8083966837153522
Secure random numbers in javascript? shows how to create a cryptographically secure Uint32Array. Maybe this could be converted to a float somehow?
- The Mozilla Uint32Array documentation was not totally clear on how to convert from an int.
- Google was not to the point, either.
Float32Array.from(someUintBuf);
always gave a whole number.
Aucun commentaire:
Enregistrer un commentaire