cmd/syncthing: Use API to generate API Key and folder ID (fixes #3179)

Expose a random string generator in the API and use it when the GUI
needs random strings for API key and folder ID.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3192
This commit is contained in:
Jakob Borg
2016-05-26 07:25:34 +00:00
committed by Audrius Butkevicius
parent e6b78e5d56
commit da5010d37a
4 changed files with 68 additions and 21 deletions

View File

@@ -89,19 +89,6 @@ function decimals(val, num) {
return decs;
}
function randomString(len) {
var chars = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
return randomStringFromCharset(len, chars);
}
function randomStringFromCharset(len, charset) {
var result = '';
for (var i = 0; i < len; i++) {
result += charset[Math.round(Math.random() * (charset.length - 1))];
}
return result;
}
function isEmptyObject(obj) {
var name;
for (name in obj) {