fast_rsa 3.8.0 copy "fast_rsa: ^3.8.0" to clipboard
fast_rsa: ^3.8.0 copied to clipboard

library for use RSA with support for android and ios, macOS, linux, windows and web

Fast RSA #

Library for use RSA with support for android, ios, macos, windows, linux and web

Integration Tests Android

Integration Tests Linux

Integration Tests Windows

Integration Tests iOS

Integration Tests macOS

Contents #

Usage #

Async Methods #

Encrypt methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.encryptOAEP(message, label, Hash.HASH_SHA256, publicKey)
var result = await RSA.encryptPKCS1v15(message, publicKey)

var result = await RSA.encryptOAEPBytes(messageBytes, label, Hash.SHA256, publicKey)
var result = await RSA.encryptPKCS1v15Bytes(messageBytes, publicKey)

copied to clipboard

Decrypt methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.decryptOAEP(message, label, Hash.HASH_SHA256, privateKey)
var result = await RSA.decryptPKCS1v15(message, privateKey)

var result = await RSA.decryptOAEPBytes(messageBytes, label, Hash.SHA256, privateKey)
var result = await RSA.decryptPKCS1v15Bytes(messageBytes, privateKey)

copied to clipboard

Sign methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.signPSS(message, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey)
var result = await RSA.signPKCS1v15(message, Hash.SHA256, privateKey)

var result = await RSA.signPSSBytes(messageBytes, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey)
var result = await RSA.signPKCS1v15Bytes(messageBytes, Hash.SHA256, privateKey)

copied to clipboard

Verify methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.verifyPSS(signature, message, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, publicKey)
var result = await RSA.verifyPKCS1v15(signature, message, Hash.SHA256, publicKey)

var result = await RSA.verifyPSSBytes(signatureBytes, messageBytes, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, publicKey)
var result = await RSA.verifyPKCS1v15Bytes(signatureBytes, messageBytes, Hash.SHA256, publicKey)

copied to clipboard

Generate Methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.generate(2048)

copied to clipboard

Convert Methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.convertJWKToPrivateKey(data, keyId);
var result = await RSA.convertJWKToPublicKey(data, keyId);

var result = await RSA.convertKeyPairToPKCS12(privateKey, certificate, password);
var result = await RSA.convertPKCS12ToKeyPair(pkcs12, password);

var result = await RSA.convertPrivateKeyToPKCS8(privateKey);
var result = await RSA.convertPrivateKeyToPKCS1(privateKey);
var result = await RSA.convertPrivateKeyToJWK(privateKey);

var result = await RSA.convertPrivateKeyToPublicKey(privateKey);

var result = await RSA.convertPublicKeyToPKIX(publicKey);
var result = await RSA.convertPublicKeyToPKCS1(publicKey);
var result = await RSA.convertPublicKeyToJWK(publicKey);

var result = await RSA.encryptPrivateKey(privateKey, password, PEMCipher.PEMCIPHER_AES256);
var result = await RSA.decryptPrivateKey(privateKeyEncrypted, password);
copied to clipboard

Util Methods

import 'package:fast_rsa/fast_rsa.dart';

var result = await RSA.hash(message, Hash.SHA256);
var result = await RSA.base64(message);

copied to clipboard

Sync Methods #

Encrypt methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.encryptOAEP(message, label, Hash.HASH_SHA256, publicKey);
var result = RSASync.encryptPKCS1v15(message, publicKey);

var result = RSASync.encryptOAEPBytes(messageBytes, label, Hash.SHA256, publicKey);
var result = RSASync.encryptPKCS1v15Bytes(messageBytes, publicKey);

copied to clipboard

Decrypt methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.decryptOAEP(message, label, Hash.HASH_SHA256, privateKey);
var result = RSASync.decryptPKCS1v15(message, privateKey);

var result = RSASync.decryptOAEPBytes(messageBytes, label, Hash.SHA256, privateKey);
var result = RSASync.decryptPKCS1v15Bytes(messageBytes, privateKey);

copied to clipboard

Sign methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.signPSS(message, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey);
var result = RSASync.signPKCS1v15(message, Hash.SHA256, privateKey);

var result = RSASync.signPSSBytes(messageBytes, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, privateKey);
var result = RSASync.signPKCS1v15Bytes(messageBytes, Hash.SHA256, privateKey);

copied to clipboard

Verify methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.verifyPSS(signature, message, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, publicKey);
var result = RSASync.verifyPKCS1v15(signature, message, Hash.SHA256, publicKey);

var result = RSASync.verifyPSSBytes(signatureBytes, messageBytes, Hash.SHA256, SaltLength.SALTLENGTH_AUTO, publicKey);
var result = RSASync.verifyPKCS1v15Bytes(signatureBytes, messageBytes, Hash.SHA256, publicKey);

copied to clipboard

Generate Methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.generate(2048)

copied to clipboard

Convert Methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.convertJWKToPrivateKey(data, keyId);
var result = RSASync.convertJWKToPublicKey(data, keyId);

var result = RSASync.convertKeyPairToPKCS12(privateKey, certificate, password);
var result = RSASync.convertPKCS12ToKeyPair(pkcs12, password);

var result = RSASync.convertPrivateKeyToPKCS8(privateKey);
var result = RSASync.convertPrivateKeyToPKCS1(privateKey);
var result = RSASync.convertPrivateKeyToJWK(privateKey);

var result = RSASync.convertPrivateKeyToPublicKey(privateKey);

var result = RSASync.convertPublicKeyToPKIX(publicKey);
var result = RSASync.convertPublicKeyToPKCS1(publicKey);
var result = RSASync.convertPublicKeyToJWK(publicKey);

var result = RSASync.encryptPrivateKey(privateKey, password, PEMCipher.PEMCIPHER_AES256);
var result = RSASync.decryptPrivateKey(privateKeyEncrypted, password);
copied to clipboard

Util Methods

import 'package:fast_rsa/fast_rsa_sync.dart';

var result = RSASync.hash(message, Hash.SHA256);
var result = RSASync.base64(message);

copied to clipboard

Setup #

Android #

No additional setup required.

iOS #

No additional setup required.

Web #

add to you pubspec.yaml

assets:
  - packages/fast_rsa/web/assets/worker.js
  - packages/fast_rsa/web/assets/wasm_exec.js
  - packages/fast_rsa/web/assets/rsa.wasm
copied to clipboard

ref: https://github.com/jerson/flutter-rsa/blob/master/example/pubspec.yaml

MacOS #

no additional setup required

Linux #

No additional setup required.

Windows #

No additional setup required.

Example #

Inside example folder

cd example && flutter run
copied to clipboard

check our web demo: [https://flutter-rsa.jerson.dev/]

Native Code #

the native library is made in Golang and build with gomobile for faster performance

https://github.com/jerson/rsa-mobile

60
likes
110
points
25.5k
downloads

Publisher

verified publisherjerson.dev

Weekly Downloads

2024.09.20 - 2025.04.04

library for use RSA with support for android and ios, macOS, linux, windows and web

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flat_buffers, flutter, flutter_web_plugins, path, plugin_platform_interface, web

More

Packages that depend on fast_rsa