Class Name | Aes |
Implements | Cryptor |
Extends | Logger |
Source | aes.ts |
Examples | aes.spec.ts |
The AES cryptor encodes and decodes content with aes-cbc.
new Aes(options);
Creates a new Aes instance.
options
-AesOptions
: options for Aes 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
Aes
instance
const aes = new Aes();
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 Aes();
const cryptoInfo = cryptor.getCryptoInfo('0x123');
cryptor.generateKey();
generate key for cryptor/decryption
Promise resolves to string
: key used for encryption.
const cryptor = new Aes();
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 Aes();
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 Aes();
const cryptoInfo = cryptor.decrypt('afeweq41f1e61e3f', { key: '0x12345' });