Encode a string in base-64:
The result of res will be:
The btoa() method encodes a string in base-64.
This method uses the "A-Z", "a-z", "0-9", "+", "/" and "=" characters to encode the string.
Tip: Use the atob() method to decode a base-64 encoded string.
The numbers in the table specify the first browser version that fully supports the method.
Method | |||||
---|---|---|---|---|---|
btoa() | Yes | 10.0 | 1.0 | Yes | Yes |
Parameter | Description |
---|---|
str | Required. The string to be encoded |
Return Value: | A String, representing the base-64 encoded string |
---|