attempt at implementing /dev/random

This commit is contained in:
b1ek 2023-03-20 21:00:05 +10:00
parent 993723865d
commit c50949576b
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 16 additions and 1 deletions

View File

@ -3,6 +3,21 @@ fs.writeFileSync('README.md', 'uwu');
const { ufs } = require('unionfs'); const { ufs } = require('unionfs');
ufs.use(fs).use(vol.fromJSON(require('./files'))); ufs.use(fs).use(vol.fromJSON(require('./files')));
ufs.constants = fs.constants;
if (!fs.existsSync('dev'))
fs.mkdirSync('dev');
// /dev/random & /dev/random
(async () => {
const delay = t => new Promise(resolve => setTimeout(resolve, t));;
const crypto = require('crypto');
while (true) {
await delay(3);
const buffer = crypto.randomBytes(16);
fs.writeFileSync('dev/urandom', buffer);
fs.writeFileSync('dev/random', buffer)
}
})();
module.exports = ufs; module.exports = ufs;