4 Best Encryption Packages for Flutter

Encryption is an important topic when it comes to working with sensitive data. The first rule of the cryptography club is to never invent a cryptography system yourself.

The following are the best Flutter encryption packages:

Table of Contents

encrypt

encrypt is a set of high-level APIs over PointyCastle for two-way cryptography. It supports AES with PKCS7 padding, RSA with PKCS1 and OAEP encoding, Salsa20, and SHA256 with RSA.

It provides a command line to create a key and iv with secure-random.

final plainText = 'This is a secret message';
final key = Key.fromUtf8('my 32 length key................');
final iv = IV.fromLength(16);

final encrypter = Encrypter(AES(key));

final encrypted = encrypter.encrypt(plainText, iv: iv);
final decrypted = encrypter.decrypt(encrypted, iv: iv);

rsa_encrypt

This package allows you to quickly implement RSA encryption in a Flutter app. It covers everything from generating key pairs, encrypt and decrypting strings.

//Future to hold our KeyPair
Future<crypto.AsymmetricKeyPair> futureKeyPair;

//to store the KeyPair once we get data from our future
crypto.AsymmetricKeyPair keyPair;

Future<crypto.AsymmetricKeyPair<crypto.PublicKey, crypto.PrivateKey>> getKeyPair()
{
	var helper = RsaKeyHelper();
	return helper.computeRSAKeyPair(helper.getSecureRandom());
}

dbcrypt

dbcrypt is a port of jBCrypt to Dart. Password can be encrypted using BCrypt and verified. It hashes passwords using a version of Bruce Schneier’s Blowfish block cipher with modifications designed to raise the cost of offline password cracking.

//generate secure password
var plainPassword = "MyPassword@123";
var hashedPassword = new DBCrypt().hashpw(plainPassword, new DBCrypt().gensalt());
//verify password
var isCorrect = new DBCrypt().checkpw(plainPassword , hashedPassword );

simple_rsa

This library can encrypt and decrypt strings with a public and a private key.

let plainText = 'something';
final signedText = await signString(plainText, utf8.decode(base64.decode(privateKey)));
final verified = await verifyString(plainText, signedText, utf8.decode(base64.decode(publicKey)));

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close