mirror of
https://github.com/linuxserver/core.git
synced 2026-02-20 05:07:19 +08:00
12 lines
290 B
JavaScript
12 lines
290 B
JavaScript
var crypto = require("crypto");
|
|
|
|
module.exports = function(length) {
|
|
var uid = "";
|
|
while (uid.length <= length) {
|
|
uid += crypto
|
|
.randomBytes(256)
|
|
.toString("base64")
|
|
.replace(/[^a-zA-Z0-9]/g, "");
|
|
}
|
|
return uid.slice(0, length);
|
|
}; |