Class: CryptTool

CryptTool()

new CryptTool()

handles everything related to en/decryption
Source:

Methods

(private, static) arraybufferToString(messageArray) → {string}

convert ArrayBuffer into a UTF-8 string Iterates over the bytes of the array, catenating them into a string
Parameters:
Name Type Description
messageArray ArrayBuffer
Source:
Returns:
message
Type
string

(static) base58decode(input) → {string}

base58 decode a DOMString (UTF-16)
Parameters:
Name Type Description
input string
Source:
Returns:
output
Type
string

(static) base58encode(input) → {string}

base58 encode a DOMString (UTF-16)
Parameters:
Name Type Description
input string
Source:
Returns:
output
Type
string

(async, static) cipher(key, password, message, adata) → {array}

compress, then encrypt message with given key and password
Parameters:
Name Type Description
key string
password string
message string
adata array
Source:
Returns:
encrypted message in base64 encoding & adata containing encryption spec
Type
array

(async, private, static) compress(message, mode, zlib) → {ArrayBuffer}

compress a string (deflate compression), returns buffer
Parameters:
Name Type Description
message string
mode string
zlib object
Source:
Throws:
string
Returns:
data
Type
ArrayBuffer

(private, static) cryptoSettings(adata, spec) → {object}

gets crypto settings from specification and authenticated data
Parameters:
Name Type Description
adata string authenticated data
spec array cryptographic specification
Source:
Returns:
crypto settings
Type
object

(async, static) decipher(key, password, data) → {string}

decrypt message with key, then decompress
Parameters:
Name Type Description
key string
password string
data string | object encrypted message
Source:
Returns:
decrypted message, empty if decryption failed
Type
string

(async, private, static) decompress(data, mode, zlib) → {string}

decompress potentially base64 encoded, deflate compressed buffer, returns string
Parameters:
Name Type Description
data ArrayBuffer
mode string
zlib object
Source:
Throws:
string
Returns:
message
Type
string

(async, private, static) deriveKey(key, password, spec) → {CryptoKey}

derive cryptographic key from key string and password
Parameters:
Name Type Description
key string
password string
spec array cryptographic specification
Source:
Returns:
derived key
Type
CryptoKey

(private, static) getRandomBytes(length) → {string}

returns specified number of random bytes
Parameters:
Name Type Description
length int number of random bytes to fetch
Source:
Throws:
string
Returns:
random bytes
Type
string

(static) getSymmetricKey() → {string}

returns a random symmetric key generates 256 bit long keys (8 Bits * 32) for AES with 256 bit long blocks
Source:
Throws:
string
Returns:
raw bytes
Type
string

(private, static) stringToArraybuffer(message) → {Uint8Array}

convert UTF-8 string into a Uint8Array Iterates over the bytes of the message, writing them to the array
Parameters:
Name Type Description
message string UTF-8 string
Source:
Returns:
array
Type
Uint8Array

(private, static) utf16To8(message) → {string}

convert DOMString (UTF-16) to a UTF-8 string stored in a DOMString URI encodes the message, then finds the percent encoded characters and transforms these hexadecimal representation back into bytes
Parameters:
Name Type Description
message string UTF-16 string
Source:
Returns:
UTF-8 string
Type
string

(private, static) utf8To16(message) → {string}

convert UTF-8 string stored in a DOMString to a standard UTF-16 DOMString Iterates over the bytes of the message, converting them all hexadecimal percent encoded representations, then URI decodes them all
Parameters:
Name Type Description
message string UTF-8 string
Source:
Returns:
UTF-16 string
Type
string