kopia lustrzana https://github.com/c9/core
12 wiersze
290 B
JavaScript
12 wiersze
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);
|
||
|
};
|