goog.crypt.base64
Functions
decodeString( input, useCustomDecoder ) → string
string
Base64-decode a string into a binary bytestring.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Base64-decode a string to an Array of numbers.
In base-64 decoding, groups of four characters are converted into three bytes. If the encoder did not apply padding, the input length may not be a multiple of 4.
In this case, the last group will have fewer than 4 characters, and padding will be inferred. If the group has one or two characters, it decodes to one byte. If the group has three characters, it decodes to two bytes.
TODO(sdh): We may want to consider renaming this to decodeToByteArray
for
consistency with decodeToText
/decodeToBinaryString
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
decodeStringToUint8Array( input ) → Uint8Array
Uint8Array
Base64-decode a string to a Uint8Array.
Note that Uint8Array is not supported on older browsers, e.g. IE < 10.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
See Also |
decodeStringUtf8( input, useCustomDecoder ) → string
string
Base64-decode a string. The input should be the result of a double-encoding a unicode string: first the unicode characters (>127) are encoded as UTF-8 bytes, and then the resulting bytes are base64-encoded.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
decodeToBinaryString( input, useCustomDecoder ) → string
string
Base64-decode a string into a binary bytestring. Note that binary strings
are discouraged now that Uint8Array is available on all supported browsers.
Users are encouraged to strongly consider decodeStringToUint8Array
. This
method is likely to be deprecated at some point in favor of the Uint8Array
version.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
decodeToText( input, useCustomDecoder ) → string
string
Base64-decode a string. The input should be the result of a double-encoding a unicode string: first the unicode characters (>127) are encoded as UTF-8 bytes, and then the resulting bytes are base64-encoded.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
encodeBinaryString( input, alphabet ) → string
string
Base64-encode a binary string. Note that binary strings are discouraged now
that Uint8Array is available on all supported browsers. Users are encouraged
to strongly consider encodeByteArray
. This method is likely to be
deprecated at some point in favor of the Uint8Array version.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
encodeByteArray( input, alphabet ) → string
string
Base64-encode an array of bytes.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
encodeString( input, alphabet, throwSync ) → string
string
Base64-encode a binary string.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
encodeStringUtf8( input, alphabet ) → string
string
Base64-encode a text string. Non-ASCII characters (charCode > 127) will be encoded as UTF-8.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
encodeText( input, alphabet ) → string
string
Base64-encode a text string. Non-ASCII characters (charCode > 127) will be encoded as UTF-8.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Properties
ENCODED_VALS → string
string
Alphabet characters for Alphabet.DEFAULT encoding.
For characters without padding, please consider using
goog.crypt.baseN.BASE_64
instead.
ENCODED_VALS_WEBSAFE → string
string
Alphabet characters for Alphabet.WEBSAFE_DOT_PADDING encoding.
The dot padding is no Internet Standard, according to RFC 4686.
https://tools.ietf.org/html/rfc4648
For characters without padding, please consider using
goog.crypt.baseN.BASE_64_URL_SAFE
instead.