Answers for "random base64 number js"

1

js code to generate random base64 code

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
Posted by: Guest on August-25-2021
24

js code to generate random base64 code

var string = "Hello folks how are you doing today?";
var encodedString = btoa(string); // Base64 encode the String
var decodedString = atob(encodedString); // Base64 decode the String
Posted by: Guest on July-31-2019

Code answers related to "Javascript"

Browse Popular Code Answers by Language