Plugin or library to do encrypt and decrypt message with RSA Crypto


To use this plugin, add rsa_crypto_algorithm as a dependency in your pubspec.yaml.


import 'dart:io';
import 'package:rsa_crypto_algorithm/rsa_key.dart' as rsaKey;
import 'package:rsa_crypto_algorithm/rsa_crypto.dart' as rsaCrypto;

main() {
  /// Take input from keybowrd
  print("Welcome to RSA Algorithm");
  print("Enter p: ");
  var p = int.parse(stdin.readLineSync());
  print("Enter q: ");
  var q = int.parse(stdin.readLineSync());

  var key = rsaKey.RSAKey();
  var n = key.valueOfN(p, q);
  var z = key.valueOfZ(p, q);
  var e = key.valueOfE(n, z);
  var d = key.valueOfD(n, e, z);
  key.generateKey(n, z, e, d);

  print("\nSelect one:");
  print("1. Encript\n2. Decript");
  var opt = int.parse(stdin.readLineSync());

  var rsa = rsaCrypto.RSACripto();
  if (opt == 1) {
    print("Enter M: ");
    var m = int.parse(stdin.readLineSync());
    var enc = rsa.encrypt(m, e, n);
    print("Encripted success: ${enc}");
  } else {
    print("Enter C: ");
    var c = int.parse(stdin.readLineSync());
    var dec = rsa.decrypt(c, d, n);
    print("Decripted success: ${dec}");

I hope this plugin or library will useful for you. Thank you so much! ~ Happy Coding ~