CipherWand class abstract
An opaque object that possesses some non-extractable secret key.
It support encrypt and/or decrypt.
Example
In this example, we use Chacha20.poly1305Aead:
import 'package:cryptography/cryptography.dart';
Future<void> main() async {
final cipher = Chacha20.poly1305Aead();
final secretKey = await cipher.newSecretKey();
final wand = await cipher.newCipherWandFromSecretKey(secretKey);
// Encrypt
final secretBox = await wand.encrypt([1,2,3]);
print('Nonce: ${secretBox.nonce}');
print('Cipher text: ${secretBox.cipherText}');
print('MAC: ${secretBox.mac.bytes}');
// Decrypt
final clearText = await wand.decrypt(secretBox);
print('Clear text: $clearText');
}
Constructors
- CipherWand.constructor()
- Constructor for subclasses.
Properties
- hasBeenDestroyed → bool
-
Whether destroy has been called.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decrypt(
SecretBox secretBox, {List< int> aad = const <int>[], Uint8List? possibleBuffer}) → Future<List< int> > - Decrypts a SecretBox and returns the clear text.
-
decryptString(
SecretBox secretBox) → Future< String> - Decrypts a string.
-
destroy(
) → Future< void> -
Prevents this object from being used anymore and attempts to erase
cryptographic keys from memory.
inherited
-
encrypt(
List< int> clearText, {List<int> ? nonce, List<int> aad = const <int>[], Uint8List? possibleBuffer}) → Future<SecretBox> -
Encrypts the
clearText
and returns the SecretBox. -
encryptString(
String clearText) → Future< SecretBox> - Encrypts a string.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited