forked from sandysound/orvibo-b25-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Utils.js
27 lines (24 loc) · 808 Bytes
/
Utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
};