MySalt - AES Encryption & Decryption
Features
- AES encryption and decryption with a secure passphrase.
- Uses a salt mechanism to ensure different encrypted outputs.
- Provides functions to verify encrypted data.
Getting started
Prerequisites
Ensure you have Flutter installed and add the required dependencies in your pubspec.yaml
file:
dependencies:
my_salt: ^1.0.0
Run the following command to install dependencies:
flutter pub get
Usage
1. Import Required Packages
import 'package:my_salt/my_salt.dart';
2. Initialize MySalt
final mySalt = MySalt();
const String passphrase = "my_secure_password";
const String originalText = "Hello, this is a secret message!";
3. Encrypt Data
String encryptedText = mySalt.encryptAESCryptoJS(originalText, passphrase);
print("Encrypted Text: $encryptedText");
4. Decrypt Data
String decryptedText = mySalt.decryptAESCryptoJS(encryptedText, passphrase);
print("Decrypted Text: $decryptedText");
5. Verify Data
bool isVerified = mySalt.verify(
text: originalText,
encrypted: encryptedText,
passphrase: passphrase,
);
print("Verification Result: $isVerified");
6. Check If Two Encrypted Texts Are Identical
String encryptedText2 = mySalt.encryptAESCryptoJS(originalText, passphrase);
bool isEncryptedEqual = mySalt.verifyEncrypted(
encrypted1: encryptedText,
encrypted2: encryptedText2,
passphrase: passphrase,
);
print("Are the encrypted texts equal? $isEncryptedEqual");
Additional information
- Salt ensures that the encrypted output is different each time.
- To decrypt correctly, you must use the same passphrase that was used for encryption.
- For bug reports and contributions, visit the GitHub repository https://github.com/ngmduc2012/my_salt.git.
- If you want to know what i do in package, checking my document here https://wong-coupon.gitbook.io/flutter/security/salt
Developer Team:
Libraries
- my_salt
- Support for doing something awesome.