I want to evaluate the pseudorandom naive random number generator(prng) in Node.js: Math.random
and also other third party prng.
The test suite I use is ENT.
The problem I face is that how to generate the input file for ENT through prng in Node.js:
function generateNumber() {
return Math.floor(Math.random() * 10)
}
const numbers = []
for (let i = 0; i < 10000000;i++) {
const r = generateNumber()
numbers.push(r)
}
let result = ''
numbers.map(function (t) { result += t })
const fs = require('fs')
fs.writeFile('output.txt', result)
the file generated from above did not work well with ENT. However, I created another file in Linux command:
dd if=/dev/random of=random_output count=8192
and this output worked well. I found that the file I created with nodejs is with 0s and 1s as a text file. Maybe the sequence should be converted to a binary file. I want to know how to modify my javascript code?
Aucun commentaire:
Enregistrer un commentaire