📅  最后修改于: 2022-03-11 15:02:57.997000             🧑  作者: Mango
function getRandomString(length) {
var randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var result = '';
for ( var i = 0; i < length; i++ ) {
result += randomChars.charAt(Math.floor(Math.random() * randomChars.length));
}
return result;
}
var randString = getRandomString(20);//get rand alphanumberic 20 char string
var randBase64String = btoa(randString); // Base64 encode the String