Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meetleev/flutter_crypto_x
A Dart library for encryption and decryption. Advanced RSA based on pointycastle.
https://github.com/meetleev/flutter_crypto_x
oaep pkcs1 rsa rsa-encryption
Last synced: 1 day ago
JSON representation
A Dart library for encryption and decryption. Advanced RSA based on pointycastle.
- Host: GitHub
- URL: https://github.com/meetleev/flutter_crypto_x
- Owner: meetleev
- License: apache-2.0
- Created: 2022-09-16T10:48:13.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-27T12:07:29.000Z (10 months ago)
- Last Synced: 2024-02-08T10:22:23.790Z (9 months ago)
- Topics: oaep, pkcs1, rsa, rsa-encryption
- Language: Dart
- Homepage:
- Size: 278 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# crypto_x
[![Pub](https://img.shields.io/pub/v/crypto_x.svg?style=flat-square)](https://pub.dev/packages/crypto_x)
[![support](https://img.shields.io/badge/platform-android%20|%20ios%20|%20web%20|%20macos%20|%20windows%20|%20linux%20-blue.svg)](https://pub.dev/packages/crypto_x)A Dart library for encryption and decryption. Advanced RSA, AES based on pointycastle.
## Features
* RSA with PKCS1 and OAEP encoding.
* Generate RSA KeyPairs and import to pem format.## Getting started
Add the package to your `pubspec.yaml`:
```yaml
dependencies:
crypto_x:
```## Usage
### AES
#### Supported modes are:
- CBC `AESMode.cbc`
- CFB-8 `AESMode.cfb8`
- CFB-128 `AESMode.cfb`
- CTR `AESMode.ctr`
- ECB `AESMode.ecb`
- OFB-128 `AESMode.ofb````dart
final key = CipherKey.fromUtf8('your key................');
final iv = CipherIV.fromLength(16);
var aes = AES(key: key, mode: AESMode.cbc);
CryptoBytes encrypted = aes.encrypt(CryptoBytes.fromUTF8('hello world.'), iv: iv);
String encryptedBase64 = decrypted.base64;
CryptoBytes decrypted = aes.decrypt(encrypted, iv: iv);
String plainText = decrypted.toString();
```### RSA
* encrypt and decrypt
```dart
var privateRSA = RSA(
privateKey: privateKey);
var publicRSA = RSA(
publicKey: publicKey);
CryptoBytes signature = publicRSA.encrypt(CryptoBytes.fromUTF8('hello world'));
String ciphertext = signature.base64;
CryptoBytes plainBytes = publicRSA.decrypt(signature);
String plainText = plainBytes.toString();
```* sign and verify
```dart
var rsaSigner = RSASigner(digestType = DigestType.sha256, privateKey: privateKey, publicKey: publicKey);
var plainBytes = CryptoBytes.fromUTF8('hello world');
CryptoBytes signature = rsaSigner.sign(plainBytes);
bool isSame = rsaSigner.verify(signature, plainBytes);
```[comment]: <> (## Additional information)