mirror of https://github.com/jitsi/jitsi-meet
parent
a5e15025f8
commit
b1f617502e
@ -0,0 +1,37 @@ |
||||
|
||||
/** |
||||
* Generates random hex number within the range [min, max] |
||||
* @param max the maximum value for the generated number |
||||
* @param min the minimum value for the generated number |
||||
* @returns random hex number |
||||
*/ |
||||
function rangeRandomHex(min, max) |
||||
{ |
||||
return Math.floor(Math.random() * (max - min) + min).toString(16); |
||||
} |
||||
|
||||
/** |
||||
* Exported interface. |
||||
*/ |
||||
var RandomUtil = { |
||||
/** |
||||
* Generates hex number with length 4 |
||||
*/ |
||||
random4digitsHex: function() { |
||||
return rangeRandomHex(4096, 65535); |
||||
}, |
||||
/** |
||||
* Generates hex number with length 8 |
||||
*/ |
||||
random8digitsHex: function() { |
||||
return rangeRandomHex(268435456, 4294967295); |
||||
}, |
||||
/** |
||||
* Generates hex number with length 12 |
||||
*/ |
||||
random12digitsHex: function() { |
||||
return rangeRandomHex(17592186044416, 281474976710655); |
||||
} |
||||
}; |
||||
|
||||
module.exports = RandomUtil; |
||||
Loading…
Reference in new issue