mirror of
https://github.com/karl0ss/orvibo-b25-server-kex.git
synced 2025-04-29 12:53:40 +01:00
28 lines
808 B
JavaScript
28 lines
808 B
JavaScript
module.exports.generateRandomTextValue = function(length) {
|
|
let chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
let result = '';
|
|
for (let i = length; i > 0; --i) {
|
|
result += chars[Math.floor(Math.random() * chars.length)];
|
|
}
|
|
return result;
|
|
};
|
|
|
|
module.exports.generateRandomHexValue = function(length) {
|
|
let chars = '0123456789abcdef';
|
|
let result = '';
|
|
for (let i = length; i > 0; --i) {
|
|
result += chars[Math.floor(Math.random() * chars.length)];
|
|
}
|
|
return result;
|
|
};
|
|
|
|
module.exports.generateRandomNumber = function(length) {
|
|
let numbers = '0123456789';
|
|
let result = '';
|
|
for (let i = length; i > 0; --i) {
|
|
result += numbers[Math.floor(Math.random() * numbers.length)];
|
|
}
|
|
return parseInt(result);
|
|
};
|
|
|