17 lines
289 B
JavaScript
17 lines
289 B
JavaScript
"use strict";
|
|
|
|
|
|
|
|
// N A T I V E
|
|
|
|
const crypto = require("crypto");
|
|
|
|
|
|
|
|
// E X P O R T
|
|
|
|
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);
|
|
};
|