Cryptor - Unencrypted

Class Name Unencrypted
Implements Cryptor
Extends Logger
Source unencrypted.ts

The Unencrypted cryptor encodes and decodes content “unencrypted” this means no encryption is applied to the content. So simply the content is public, only HEX encoded.


constructor

new Unencrypted(options);

Creates a new Unencrypted instance.

Parameters

  1. options - UnencryptedOptions: options for Unencrypted constructor.
    • log - Function (optional): function to use for logging: (message, level) => {...}
    • logLevel - LogLevel (optional): messages with this level will be logged with log
    • logLog - LogLogInterface (optional): container for collecting log messages
    • logLogLevel - LogLevel (optional): messages with this level will be pushed to logLog

Returns

Unencrypted instance

Example

const unencrypted = new Unencrypted();

getCryptoInfo

cryptor.getCryptoInfo(originator);

create new crypto info for this cryptor

Parameters

  1. originator - string: originator or context of the encryption

Returns

CryptoInfo: details about encryption for originator with this cryptor.

Example

const cryptor = new Unencrypted();
const cryptoInfo = cryptor.getCryptoInfo('0x123');

generateKey

cryptor.generateKey();

generate key for cryptor/decryption

Returns

Promise resolves to string: key used for encryption.

Example

const cryptor = new Unencrypted();
const cryptoInfo = cryptor.generateKey();

encrypt

cryptor.encrypt(message, options);

‘encrypt’ a message (serializes message)

Parameters

  1. message - string: message which should be encrypted
  2. options - any: cryptor options
    • key - string: key used for encryption

Returns

Promise resolves to string: encrypted message.

Example

const cryptor = new Unencrypted();
const cryptoInfo = cryptor.encrypt('Hello World', { key: '0x12345' });

decrypt

cryptor.decrypt(message, options);

‘decrypt’ a message (deserializes message)

Parameters

  1. message - Buffer: message which should be decrypted
  2. options - any: cryptor options
    • key - string: key used for encryption

Returns

Promise resolves to any: decrypted message.

Example

const cryptor = new Unencrypted();
const cryptoInfo = cryptor.decrypt('afeweq41f1e61e3f', { key: '0x12345' });