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

Developer Team:

Any comments please contact us ThaoDoan and DucNguyen

Buy Me A Coffee

Support Me on Ko-fi

Libraries

my_salt
Support for doing something awesome.