2018-08-10 17:29:06 -05:00
|
|
|
"use strict";
|
|
|
|
|
2018-08-14 15:15:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
// P A C K A G E
|
|
|
|
|
2018-08-10 17:29:06 -05:00
|
|
|
const crypto = require("crypto");
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 15:15:27 -05:00
|
|
|
// E X P O R T
|
|
|
|
|
2018-08-10 17:29:06 -05: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);
|
|
|
|
};
|