1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
Description: improve hard-to-guess temp names
Author: Jérémy Lal <kapouer@melix.org>
Last-Update: 2019-01-10
Forwarded: https://github.com/bruce/node-temp/pull/81
--- a/lib/temp.js
+++ b/lib/temp.js
@@ -1,5 +1,6 @@
var fs = require('fs'),
path = require('path'),
+ crypto = require('crypto'),
cnst = require('constants');
var rimraf = require('rimraf'),
@@ -18,7 +19,7 @@
'-',
process.pid,
'-',
- (Math.random() * 0x100000000 + 1).toString(36),
+ crypto.randomBytes(6).toString('hex'),
affixes.suffix].join('');
return path.join(affixes.dir || exports.dir, name);
};
|