javascriptnode.jsrandombiginteger

Random Big Integer In Range JavaScript


I need a random integer between 0 and an integer with over 1000 decimal places.

Working with integers this large is easy with: big-integer (NPM), but there is no random method, and Math.random() doesn't express enough precision to cover the domain.

Does anyone know a clever way of generating pseudo random integers in a large range in JavaScript?


Solution

  • I think best solution for your case in Node.JS is crypto.randomBytes(size, [callback]);