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