Created
May 26, 2014 15:18
-
-
Save sharnie/a11ae1264c8af4d714e4 to your computer and use it in GitHub Desktop.
Javascript encode and decode string with base64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the string | |
var string = 'Hello World!'; | |
// Encode the String | |
var encodedString = btoa(string); | |
console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh" | |
// Decode the String | |
var decodedString = atob(encodedString); | |
console.log(decodedString); // Outputs: "Hello World!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment