Generate a random API key on initial setup (fixes #1118)
Also makes the javascript implementation use the same algorithm for generating random strings.
This commit is contained in:
@@ -104,15 +104,12 @@ function decimals(val, num) {
|
||||
return decs;
|
||||
}
|
||||
|
||||
function randomString(len, bits) {
|
||||
bits = bits || 36;
|
||||
var outStr = "",
|
||||
newStr;
|
||||
while (outStr.length < len) {
|
||||
newStr = Math.random().toString(bits).slice(2);
|
||||
outStr += newStr.slice(0, Math.min(newStr.length, (len - outStr.length)));
|
||||
function randomString(len) {
|
||||
var i, result = '', chars = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
|
||||
for (i = 0; i < len; i++) {
|
||||
result += chars[Math.round(Math.random() * (chars.length - 1))];
|
||||
}
|
||||
return outStr.toLowerCase();
|
||||
return result;
|
||||
}
|
||||
|
||||
function isEmptyObject(obj) {
|
||||
|
||||
Reference in New Issue
Block a user