diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/utils.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/helpers/utils.js b/server/helpers/utils.js index 1f7839673..9d4d51c46 100644 --- a/server/helpers/utils.js +++ b/server/helpers/utils.js | |||
@@ -1,9 +1,20 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const crypto = require('crypto') | ||
4 | |||
3 | const logger = require('./logger') | 5 | const logger = require('./logger') |
4 | 6 | ||
5 | const utils = { | 7 | const utils = { |
6 | cleanForExit: cleanForExit | 8 | cleanForExit: cleanForExit, |
9 | generateRandomString: generateRandomString | ||
10 | } | ||
11 | |||
12 | function generateRandomString (size, callback) { | ||
13 | crypto.pseudoRandomBytes(size, function (err, raw) { | ||
14 | if (err) return callback(err) | ||
15 | |||
16 | callback(null, raw.toString('hex')) | ||
17 | }) | ||
7 | } | 18 | } |
8 | 19 | ||
9 | function cleanForExit (webtorrent_process) { | 20 | function cleanForExit (webtorrent_process) { |