Skip to content

infinity.aes256

Provides AES-256 encryption and decryption functionality for strings, files and streams.

Module: infinity.crypto

Example:

infinity.loadModule('infinity.crypto');

let encryptedData = infinity.aes256.encrypt("dataToEncrypt", 'secretPW123');
console.debug(encryptedData);
//KIePX+E74PscojA/8rkxBDD3Yzgk

let decryptedData = infinity.aes256.decrypt(encryptedData, 'secretPW123');
console.debug(decryptedData);
//dataToEncrypt

Functions

decrypt()

Attempts to decrypt the given string with AES-256 and returns the results.

Signature:

decrypt( value: string, password: string ): string

Parameters:

  • value: string

    The string to decrypt.

  • password: string

    The password used previously during encryption.

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let decryptedData = infinity.aes256.decrypt(encryptedData, 'secretPW123');

decryptFile()

Reads out the contents of the given file, attempts to decrypt them with AES-256 and writes the results to a file at the specified location.

Signature:

decryptFile( inFileName: string, outFileName: string, password: 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 encrypted 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 decrypted output.

  • password: string

    The password used previously during encryption.

Example:

infinity.loadModule('infinity.crypto');
infinity.aes256.decryptFile('encryptedData.txt', 'decryptedData.txt', 'secretPW123');

decryptStream()

Reads the contents of the given stream, attempts to decrypt them with AES-256 and writes the results to another given stream.

Signature:

decryptStream( inStream: infinity.stream, outStream: infinity.stream, password: string ): void

Parameters:

Example:

infinity.loadModule('infinity.crypto');
infinity.aes256.decryptStream(inStream, outStream, 'secretPW123');

encrypt()

Encrypts the given string with AES-256 and returns the results.

Signature:

encrypt( value: string, password: string ): string

Parameters:

  • value: string

    The string to encrypt.

  • password: string

    The password to be used later for decryption.

Return type: string

Example:

infinity.loadModule('infinity.crypto');
let encryptedData = infinity.aes256.encrypt(dataToEncrypt, 'secretPW123');

encryptFile()

Reads out the contents of the given file, encrypts them with AES-256 and writes the results to a file at the specified location.

Signature:

encryptFile( inFileName: string, outFileName: string, password: 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 file which has to be encrypted.

  • 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 encrypted output.

  • password: string

    The password to be used later for decryption.

Example:

infinity.loadModule('infinity.crypto');
infinity.aes256.encryptFile('dataToEncrypt.txt', 'encryptedData.txt', 'secretPW123');

encryptStream()

Reads the contents of the given stream, encrypts them with AES-256 and writes the results to another given stream.

Signature:

encryptStream( inStream: infinity.stream, outStream: infinity.stream, password: string ): void

Parameters:

Example:

infinity.loadModule('infinity.crypto');
infinity.aes256.encryptStream(inStream, outStream, 'secretPW123');