Simple RSA Encryption #
Flutter plugin to encrypt, decrypt (RSA/ECB/PCSK1), verify and sign string with a public and a private key
Support for ANDROID and iOS(thanks to adlanarifzr)
To use the plugin, add
simple_rsa as a
dependency in your pubspec.yaml file.
First, initialize private and public key. Preferably in BASE64 format.
final publicKey = '...'; final privateKey = '...';
After that, you can encrypt or decyrpt text
let plainText = 'something'; final encryptedText = await encryptString(plainText, utf8.decode(base64.decode(publicKey))); final decryptedText = await decryptString(encryptedText, utf8.decode(base64.decode(privateKey))); // Test print(plainText == decryptedText ? 'true' : 'false');
Or you might want to sign and verify text
let plainText = 'something'; final signedText = await signString(plainText, utf8.decode(base64.decode(privateKey))); final verified = await verifyString(plainText, signedText, utf8.decode(base64.decode(publicKey))); // Test print(verified ? 'true' : 'false');
See the example application source for a complete sample app using the Simple RSA encryption.
Adlan Arif Zakaria (adlanarifzr) iOS compatibility, sign and verify method.
- Migrate to AndroidX
- Edit encryptData for support input size greater then 512 bytes
- Fixed iOS functions and optimize the code
- Add method for decrypt string (more 512 byte) with public key (ANDROID)
- Add iOS compatibility
- Add signData and verifyData method
- Initial experimentation
Demonstrates how to use the simple_rsa plugin.
Getting Started #
For help getting started with Flutter, view our online documentation.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: simple_rsa: ^0.0.5
2. Install it
You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.5.0
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.2
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Health issues and suggestions
Document public APIs. (-1 points)
6 out of 6 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.
flutter format to format
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of
0.0.*, it might mean that the author is still experimenting with the general direction of the API.