aes256 2.2.0 copy "aes256: ^2.2.0" to clipboard
aes256: ^2.2.0 copied to clipboard

AES-256 encryption and decryption using PBKDF2 + AES-GCM.

๐Ÿ” AES256 #

A lightweight, modern, and secure AES-256-GCM encryption library for Dart & Flutter.
Designed with strong defaults, clean APIs, and seamless usability across mobile, web, and server environments.

๐Ÿ‘‰ Live Demo: https://knottx.dev/aes256


๐Ÿš€ Features #

  • AES-256-GCM โ€” Authenticated encryption with integrity protection
  • PBKDF2-HMAC-SHA256 โ€” Strong password-based key derivation
  • 100,000 iterations โ€” Secure default against brute-force attacks
  • Random salt & nonce โ€” Automatically handled
  • Stateless API โ€” Easy to integrate into any architecture
  • Pure Dart โ€” Works on Flutter, Dart VM, and Web

๐Ÿ”ง Usage #

import 'package:aes256/aes256.dart';

void main() async {
  // Encrypt
  final encrypted = await Aes256.encrypt(
    text: 'Hello world',
    passphrase: 'my-passphrase',
  );

  // Decrypt
  final decrypted = await Aes256.decrypt(
    encrypted: encrypted,
    passphrase: 'my-passphrase',
  );

  print(decrypted); // Hello world
}

๐Ÿ”’ How It Works #

AES256 outputs a structured, self-contained binary payload:

salt(16) + nonce(12) + ciphertext + tag

Security Parameters #

Component Value
Cipher AES-256-GCM
Key Derivation PBKDF2-HMAC-SHA256
Iterations 100,000
Salt 16 bytes (random, public)
Nonce 12 bytes (random, public)
Auth Tag 16 bytes
Integrity Built-in (GCM tag)

Why salt & nonce are public #

Salt and nonce do not provide secrecy by themselves โ€” they ensure uniqueness and key strengthening.
The passphrase-derived key is the only secret.
Exposing salt/nonce does not weaken the encryption.


๐Ÿงช Example Output (Base64) #

QTI1NkdDTQEBEBcAAAAAAAAAACZ1FqvXโ€ฆ(ciphertext)โ€ฆLk5h0nA=

๐Ÿ›ก๏ธ Security Notes #

  • Always use a strong passphrase
  • AES-GCM requires a unique nonce per encryption โ€” this library handles it automatically
  • For high-security systems, keep actual keys in secure storage or server-side only

โ“ FAQ #

Is the encrypted output safe to store publicly? #

Yes โ€” as long as the passphrase remains secret.

Can I decrypt data encrypted in another language? #

Yes โ€” as long as the other implementation uses the same payload structure and AES-256-GCM + PBKDF2-SHA256 parameters.

This library follows a clean and predictable binary format:

salt(16) + nonce(12) + ciphertext + tag

Any implementation that generates output in the same sequence will decrypt correctly.

Does it work on Flutter Web? #

Yes โ€” it is pure Dart with no native bindings.

5
likes
0
points
3.08k
downloads

Publisher

verified publisherknottx.dev

Weekly Downloads

AES-256 encryption and decryption using PBKDF2 + AES-GCM.

Homepage
Repository (GitHub)
View/report issues

Topics

#aes #aes256 #aes-gcm #gcm #pbkdf2

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

cryptography

More

Packages that depend on aes256