Cryptor - AES ECB¶
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.
constructor¶
new AesEcb(options);
Creates a new AesEcb instance.
Parameters¶
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
Returns¶
AesEcb
instance
getCryptoInfo¶
cryptor.getCryptoInfo(originator);
create new crypto info for this cryptor
Parameters¶
originator
-string
: originator or context of the encryption
Returns¶
CryptoInfo
: details about encryption for originator with this cryptor.
generateKey¶
cryptor.generateKey();
generate key for cryptor/decryption
Returns¶
Promise resolves to string
: key used for encryption.
encrypt¶
cryptor.encrypt(message, options);
‘encrypt’ a message (serializes message)
Parameters¶
message
-string
: message which should be encryptedoptions
-any
: cryptor optionskey
-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¶
message
-Buffer
: message which should be decryptedoptions
-any
: cryptor optionskey
-string
: key used for encryption
Returns¶
Promise resolves to any
: decrypted message.
Example¶
const cryptor = new Unencrypted();
const cryptoInfo = cryptor.decrypt('afeweq41f1e61e3f', { key: '0x12345' });