Module: util/util

util/util

This object contains utility functions
Source:

Requires

Methods

<static> bin2str(bin) → {String}

Convert an array of integers(0.255) to a string
Parameters:
Name Type Description
bin Array.<Integer> An array of (binary) integers to convert
Source:
Returns:
The string representation of the array
Type
String

<static> calc_checksum(text) → {Integer}

Calculates a 16bit sum of a string by adding each character codes modulus 65535
Parameters:
Name Type Description
text String String to create a sum of
Source:
Returns:
An integer containing the sum of all character codes % 65535
Type
Integer

<static> decode_utf8(utf8) → {String}

Convert a string of utf8 bytes to a native javascript string
Parameters:
Name Type Description
utf8 String A valid squence of utf8 bytes
Source:
Returns:
A native javascript string
Type
String

<static> encode_utf8(str) → {String}

Convert a native javascript string to a string of utf8 bytes
Parameters:
Name Type Description
str String The string to convert
Source:
Returns:
A valid squence of utf8 bytes
Type
String

<static> get_hashAlgorithmString() → {String}

Return the algorithm type as string
Source:
Returns:
String representing the message type
Type
String

<static> hex2bin(str) → {String}

Create binary string from a hex encoded string
Parameters:
Name Type Description
str String Hex string to convert
Source:
Returns:
String containing the binary values
Type
String

<static> hexidump(str) → {String}

Creating a hex string from an binary array of integers (0..255)
Parameters:
Name Type Description
str String Array of bytes to convert
Source:
Returns:
Hexadecimal representation of the array
Type
String

<static> hexstrdump(str) → {String}

Create hexstring from a binary
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
String containing the hexadecimal values
Type
String
Helper function to print a debug message. Debug messages are only printed if
Parameters:
Name Type Description
str String String of the debug message
Source:
Helper function to print a debug message. Debug messages are only printed if
Parameters:
Name Type Description
str String String of the debug message
Source:

<static> shiftRight(value, bitcount) → {String}

Shifting a string to n bits right
Parameters:
Name Type Description
value String The string to shift
bitcount Integer Amount of bits to shift (MUST be smaller than 9)
Source:
Returns:
Resulting string.
Type
String

<static> str2bin(str) → {Array.<Integer>}

Convert a string to an array of integers(0.255)
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
An array of (binary) integers
Type
Array.<Integer>

<static> str2Uint8Array(str) → {Uint8Array}

Convert a string to a Uint8Array
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
The array of (binary) integers
Type
Uint8Array

<static> Uint8Array2str(bin) → {String}

Convert a Uint8Array to a string. This currently functions the same as bin2str.
Parameters:
Name Type Description
bin Uint8Array An array of (binary) integers to convert
Source:
Returns:
String representation of the array
Type
String