Window btoa() method
Definition and Usage
The btoa() method is used to create a base-64 encoded string.
This method uses the characters "A-Z", "a-z", "0-9", "+", "/" and "=" to encode the string.
The base-64 decoding usage is atob() .
Syntax
window.btoa(str)
Parameter Description:
- str: Required, the string to encode.
Return Value
This method returns a base-64 encoded string
Browser support
The numbers in the table indicate the first browser version that supports this method.
| Method | |||||
|---|---|---|---|---|---|
| btoa() | Yes | 10.0 | 1.0 | Yes | Yes |
Example
Example
Create a base-64 encoded string:
var
str
=
"
RUNOOB
"
;
var
enc
=
window
.
btoa
(
str
)
;
var
res
=
"
Encoded string:
"
enc
;
Try it »
Window Object