Skip to content

A high-level AES encryption/decryption dart library compatible with Rob Napier's RNCryptor for iOS.

License

Notifications You must be signed in to change notification settings

tzraikov/flutter_rncryptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter RNCryptor package

A high-level AES encryption/decryption library compatible with Rob Napier's RNCryptor for iOS. This implementation is based on JSCryptor and uses pointycastle under the hood.

RNCryptor specification can be found here.

Usage

First import it in your Dart code:

import 'package:rncryptor/rncryptor.dart';

Using RNCryptor is simple, just call the encrypt method to encrypt your text by using the specified password:

var encrypted = RNCryptor.encrypt('my password', 'some plain text');

Call decrypt method to decrypt the encrypted text:

var encrypted = RNCryptor.decrypt('my password', 'an encrypted message');

Converting a password into a key is intentionally slow. In case your app encrypts/decrypts many short messages, using password would have a significant performance impact. In that case using keys would be preferred.

Use the generateKey method to generate a new key from a password and a salt:

var salt = RNCryptor.generateSalt();
var encryptKey = RNCryptor.generateKey('my password', salt);

RNCryptor uses two 256-bit (32 byte) length keys for encryption and authentication. The encryptWithKey method encrypts the message with the specified keys:

RNCryptor.encryptWithKey(encryptKey, hmacKey, 'some plain text');

Call the decryptWithKey method to decrypt a message encrypted with a known key:

RNCryptor.decryptWithKey(encryptKey, hmacKey, 'an encrypted message');

About

A high-level AES encryption/decryption dart library compatible with Rob Napier's RNCryptor for iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published