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 method isatob() 。
Syntax
window.btoa(str)
Parameter description:
- str: Required. The string to be encoded.
Return Value
This method returns a base-64 encoded string.Browser Support
The numbers in the table specify the first browser version that fully supports the method.
| Method | |||||
|---|---|---|---|---|---|
| btoa() | Yes | 10.0 | 1.0 | Yes | Yes |
Example
Example
Create a base-64 encoded string:
var str = "EXAMPLE";
var enc = window.btoa(str);
var res = "Encoded string:" + enc;
Try it Yourself »
Other Extensions
Window Object