Class Name | AesEcb |
---|---|
Implements | Cryptor |
Extends | Logger |
Source | aes-ecb.ts |
Examples | aes-ecb.spec.ts |
The AES ECB cryptor encodes and decodes content with aes-ecb.
new AesEcb(options);
Creates a new AesEcb instance.
options
-AesEcbOptions
: options for AesEcb constructor.log
-Function
(optional): function to use for logging:(message, level) => {...}
logLevel
-LogLevel
(optional): messages with this level will be logged withlog
logLog
-LogLogInterface
(optional): container for collecting log messageslogLogLevel
-LogLevel
(optional): messages with this level will be pushed tologLog
AesEcb
instance
const aesEcb = new AesEcb();
cryptor.getCryptoInfo(originator);
create new crypto info for this cryptor
originator
-string
: originator or context of the encryption
CryptoInfo
: details about encryption for originator with this cryptor.
const cryptor = new AesEcb();
const cryptoInfo = cryptor.getCryptoInfo('0x123');
cryptor.generateKey();
generate key for cryptor/decryption
Promise resolves to string
: key used for encryption.
const cryptor = new Unencrypted();
const cryptoInfo = cryptor.generateKey();
cryptor.encrypt(message, options);
'encrypt' a message (serializes message)
message
-string
: message which should be encryptedoptions
-any
: cryptor optionskey
-string
: key used for encryption
Promise resolves to string
: encrypted message.
const cryptor = new Unencrypted();
const cryptoInfo = cryptor.encrypt('Hello World', { key: '0x12345' });
cryptor.decrypt(message, options);
'decrypt' a message (deserializes message)
message
-Buffer
: message which should be decryptedoptions
-any
: cryptor optionskey
-string
: key used for encryption
Promise resolves to any
: decrypted message.
const cryptor = new Unencrypted();
const cryptoInfo = cryptor.decrypt('afeweq41f1e61e3f', { key: '0x12345' });