infinity.base64¶
Provides Base64-encoding and decoding functionality for strings, files and streams.
Module: infinity.encoding
Example:
infinity.loadModule('infinity.encoding');
let encodedData = infinity.base64.encode('AUO_ÄÜÖ ß-"+&,?.<=>');
console.debug(encodedData);
//QVVPX8OEw5zDliDDny0iKyYsPy48PT4=
let decodedData = infinity.base64.decode(encodedData);
console.debug(decodedData);
//AUO_ÄÜÖ ß-"+&,?.<=>
decode()¶
Attempts to decode the given string from Base64 and returns the results.
Signature:
decode( value: string, encoding?: infinity.encoding ): string
Parameters:
-
value:
string
The string to decode.
-
encoding:
infinity.encoding
enums), optionalThe target encoding (one of the infinity.encoding enums).
Return type: string
Example:
infinity.loadModule('infinity.encoding');
let decodedData = infinity.base64.decode(encodedData, infinity.encoding.utf8);
decodeFile()¶
Reads out the contents of the given file, attempts to decode them from Base64 and returns the results.
Signature:
decodeFile( fileName: string ): string
Parameters:
- fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the encoded file.
Return type: string
Example:
infinity.loadModule('infinity.encoding');
let decodedData = infinity.base64.decodeFile('encodedData.txt');
decodeFile()¶
Reads out the contents of the given file, attempts to decode them from Base64 and writes the results to a file at the specified location.
Signature:
decodeFile( inFileName: string, outFileName: string ): void
Parameters:
-
inFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the encoded file.
-
outFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the decoded output.
Example:
infinity.loadModule('infinity.encoding');
infinity.base64.decodeFile('encodedData.txt', 'decodedData.txt');
decodeStream()¶
Reads the contents of the given stream, attempts to decode them from Base64 and writes the results to another given stream.
Signature:
decodeStream( inStream: infinity.stream, outStream: infinity.stream ): void
Parameters:
-
inStream:
infinity.stream
The stream object to decode from. See infinity.stream.
-
outStream:
infinity.stream
The stream object to write to. See infinity.stream.
Example:
infinity.loadModule('infinity.encoding');
infinity.base64.decodeStream(inStream, outStream);
encode()¶
Encodes the given string with Base64 and returns the results.
Signature:
encode( value: string, encoding?: infinity.encoding ): string
Parameters:
-
value:
string
The string to encode.
-
encoding:
infinity.encoding
, optionalThe source encoding (one of the infinity.encoding enums).
Return type: string
Example:
infinity.loadModule('infinity.encoding');
let encodedData = infinity.base64.encode(dataToEncode, infinity.encoding.utf8);
encodeFile()¶
Reads out the contents of the given file, encodes them to Base64 and writes the results to a file at the specified location.
Signature:
encodeFile( inFileName: string, outFileName: string ): void
-
inFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which has to be encoded.
-
outFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the encoded output.
Example:
infinity.loadModule('infinity.encoding');
infinity.base64.encodeFile('dataToEncode.txt', 'encoded.txt');
encodeFile()¶
Reads out the contents of the given file, encodes them to Base64 and returns the results.
Signature:
encodeFile( fileName: string ): string
Parameters:
- fileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which has to be encoded.
Return type: string
Example:
infinity.loadModule('infinity.encoding');
let encodedData = infinity.base64.encodeFile('dataToEncode.txt');
encodeStream()¶
Reads the contents of the given stream, encodes them to Base64 and writes the results to another given stream.
Signature:
encodeStream( inStream: infinity.stream, outStream: infinity.stream ): void
Parameters:
-
inStream:
infinity.stream
The stream object to encode data from. See infinity.stream.
-
outStream:
infinity.stream
The stream object to write to. See infinity.stream.
Example:
infinity.loadModule('infinity.encoding');
infinity.base64.encodeStream(inStream, outStream);