Skip to content

Commit 620e35f

Browse files
committed
base64
1 parent c6ce0db commit 620e35f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// 14. JavaScript | Encode/Decode a string to Base64
2+
3+
// 1. btoa() Method
4+
5+
// window.btoa( String )
6+
7+
function encodeStr() {
8+
console.log(btoa(str1));
9+
}
10+
11+
const str1 = "This is amit";
12+
encodeStr();
13+
14+
// 2. atob() Method
15+
16+
//window.atob( String )
17+
function decodeStr() {
18+
console.log(atob(str2));
19+
}
20+
21+
const str2 = "VGhpcyBpcyBhbWl0";
22+
decodeStr();

0 commit comments

Comments
 (0)