my_salt 1.2.0
my_salt: ^1.2.0 copied to clipboard
Authenticated text and binary encryption for Dart with AES-256-GCM, associated data, rotation, and CryptoJS migration.
import 'package:my_salt/my_salt.dart';
Future<void> main() async {
const mySalt = MySalt();
const passphrase = 'use-a-long-random-passphrase';
const originalText = 'Hello, this is a secret message!';
// 1. Encrypt the text.
final encryptedText = await mySalt.encrypt(originalText, passphrase);
// 2. Decrypt it with the same passphrase.
final decryptedText = await mySalt.decrypt(encryptedText, passphrase);
// 3. Verify without exposing decryption failures.
final isVerified = await mySalt.verifyAuthenticated(
text: originalText,
encrypted: encryptedText,
passphrase: passphrase,
);
print('Encrypted text: $encryptedText');
print('Decrypted text: $decryptedText');
print('Verification result: $isVerified');
}