Base64 encoding and decoding for binary data and strings.
- Copyright:
- Copyright (C) 1999 Masanao Izumo
- Copyright (C) 1999 Masanao Izumo
- Source:
Methods
-
<static> decode(str, encoding) → {string|ByteArray}
-
Decodes a Base64 encoded string to a string or byte array.
Parameters:
Name Type Argument Description str
String the Base64 encoded string
encoding
String <optional>
the encoding to use for the return value. Defaults to 'utf8'. Use 'raw' to get a ByteArray instead of a string. Other valid values are 'utf8', 'ascii' and 'ucs2'.
- Source:
Returns:
The decoded string or ByteArray
- Type
- string | ByteArray
Example
strings = require("ink-strings"); strings.decode( "XDc3L1tdMDk4NzQzMmZnZnN1amRuZm9za3N1d20qJl4lJCNA" ); -> '\\77/[]0987432fgfsujdnfosksuwm*&^%$#@'
-
<static> encode(str, encoding) → {string}
-
Encode a string or binary to a Base64 encoded string
Parameters:
Name Type Argument Description str
String | Binary A string or binary object to encode
encoding
String <optional>
Encoding to use if first argument is a string. Defaults to 'utf8'. Valid values are 'utf8', 'ascii' and 'ucs2'.
- Source:
Returns:
The Base64 encoded string
- Type
- string
Example
strings = require("ink-strings"); strings.encode( "\\77/[]0987432fgfsujdnfosksuwm*&^%$#@" ) ->'XDc3L1tdMDk4NzQzMmZnZnN1amRuZm9za3N1d20qJl4lJCNA'