mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-11 20:09:18 +08:00
Generated documentation :)
This commit is contained in:
14
src/util.js
14
src/util.js
@@ -121,6 +121,13 @@ let getRandomBytes = ((typeof window !== 'undefined' && window.crypto)
|
||||
: function () {
|
||||
return require("crypto").randomBytes;
|
||||
})();
|
||||
/**
|
||||
* Returns a random integer between min (inclusive) and max (exclusive).
|
||||
* @param {number} min The minimum value.
|
||||
* @param {number} max The maximum value.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function getCryptoRandomInt(min, max) {
|
||||
// synchronous version of: https://github.com/joepie91/node-random-number-csprng
|
||||
const range = max - min;
|
||||
@@ -151,6 +158,13 @@ function getCryptoRandomInt(min, max) {
|
||||
}
|
||||
}
|
||||
exports.getCryptoRandomInt = getCryptoRandomInt;
|
||||
/**
|
||||
* Generates a random string of length `length` from the characters in `chars`.
|
||||
* @param {number} length The number of characters to generate.
|
||||
* @param {string} chars A string containing all the possible characters to use for generating the random string.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function genSecret(length = 64) {
|
||||
let secret = "";
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
Reference in New Issue
Block a user