vendredi 16 août 2019

sodium VS csprng

I've been looking for the best CSPRNG in javascript/nodejs.

window.crypto.getRandomValues() seems to not be always available and may cause some issues if not;

There's also a discussion about some issues with crypto.randomBytes() in https://github.com/nodejs/node/issues/5798;

Then I've found two approaches:

var random1 = require('sodium').Random.randombytes_buf(32);
and
require('csprng')(256, 36); //256 is the number of the bits and 36 is the base I'm using now (if it was 2, only 0's and 1's would be printed)

Which one is the best between random1 and random2?




Aucun commentaire:

Enregistrer un commentaire