Module: ink/strings/base64

ink/strings/base64

Base64 encoding and decoding for binary data and strings.

Author:
  • Masanao Izumo
  • Kris Kowal
  • Christoph Dorn
  • Hannes Wallnoefer
  • Terry Weiss
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'
See NOTICE.md for licenses
ink-strings Copyright contributers to ink-strings, base64, Helma, RingoJS, sprintf projects.
Documentation generated by JSDoc 3.2.0-dev on Sun Jun 09 2013 11:56:07 GMT-0400 (EDT) using the DocStrap template.