2018-08-11 00:29:06 +02:00
|
|
|
"use strict";
|
|
|
|
|
2018-08-14 22:15:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
// P A C K A G E
|
|
|
|
|
2018-08-11 00:29:06 +02:00
|
|
|
const crypto = require("crypto");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 22:15:27 +02:00
|
|
|
// E X P O R T
|
|
|
|
|
2018-08-11 00:29:06 +02:00
|
|
|
module.exports = exports = len => {
|
|
|
|
if (!Number.isFinite(len)) throw new TypeError("Expected a finite number");
|
|
|
|
return crypto.randomBytes(Math.ceil(len / 2)).toString("hex").slice(0, len);
|
|
|
|
};
|