aws_encryption_sdk 1.0.0 aws_encryption_sdk: ^1.0.0 copied to clipboard
An implementation of the AWS Encryption SDK in Dart. Encrypt and decrypt data using AWS KMS, AES and RSA keys. Interoperates with the Java, C and Python implementations.
Example Usage #
- Instantiate an
AwsCrypto
- Instatiate a keyring of the appropriate type
- Call
encryptData
and/ordecryptData
- the result is aCryptoResult
import 'package:aws_encryption_sdk/aws_encryption_sdk.dart';
main() async {
// Instantiate an instance of the library, with the defaults
final awsCrypto = AwsCrypto();
// Instantiate a keyring, using an AWS KMS key id
final keyring = AwsKmsKeyring(
'arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f',
);
// encrypt the data with the keyring
final encryptionResult = await awsCrypto.encryptData(
data: data,
keyring: keyring,
);
}
List of complete examples provided #
example/aws_kms_example.dart
Uses an AWS KMS key to encrypt and decryptexample/raw_aes_example.dart
Encrypts and decrypts under a 256-bit AES keyexample/raw_multi_example.dart
Encrypts under both an RSA public key and AES key, then decrypts using each individuallyexample/streaming_example.dart
Demonstrates encryption/decryption of data using streams (useful when the data is too big to fit in memory)