rsa_util 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

rsa_util #

rsa util

Getting Started #

import 'package:rsa_util/rsa_util.dart';

void main(){

    const s = "This is a test by RSA 123456 !"; //the s length limit 127
    
    //如果你没有密匙,你可以生成一个,像下面这样,生成1024位的公匙和私匙

    List<String> keys = RSAUtil.generateKeys(1024);
    
    final String pubKey = keys[0];
    
    final String priKey = keys[1];
    
    //如果你有密匙,你可以直接调用下面这个方法

    RSAUtil rsa = RSAUtil.getInstance(pubKey, priKey);
    
    var jiami = rsa.encryptByPublicKey(s);
    
    print("公匙加密" + jiami);
    
    var jiemi = rsa.decryptByPrivateKey(jiami);
    
    print("私匙解密" + jiemi);
    

    var jiami2 = rsa.encryptByPrivateKey(s);
    
    print("私匙加密" + jiami2);

    var jiemi2 = rsa.decryptByPublicKey(jiami2);
    
    print("公匙解密" + jiemi2);

}

0.0.7 #

  • Added 生成公匙和私匙,以及使用任意的字符串做为密匙
  • 用公匙加密,用私匙解密
  • 用私匙加密,用公匙解密

example/main.dart

import 'package:rsa_util/rsa_util.dart';

void main(){

  const s = "This is a sss test by RSA 123456 !"; //the s length limit 117

  //如果你没有密匙,你可以生成一个,像下面这样,生成1024位的公匙和私匙
  List<String> keys = RSAUtil.generateKeys(1024);
  final String pubKey = keys[0];
  final String priKey = keys[1];

  //如果你有密匙,你可以直接调用下面这个方法
  RSAUtil rsa = RSAUtil.getInstance(pubKey, priKey);

  var jiami = rsa.encryptByPublicKey(s);
  print("公匙加密" + jiami);

  var jiemi = rsa.decryptByPrivateKey(jiami);
  print("私匙解密" + jiemi);

  var jiami2 = rsa.encryptByPrivateKey(s);
  print("私匙加密" + jiami2);

  var jiemi2 = rsa.decryptByPublicKey(jiami2);
  print("公匙解密" + jiemi2);

}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  rsa_util: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:rsa_util/rsa_util.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Dec 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
asn1lib ^0.5.8 0.5.15
pedantic ^1.7.0 1.9.0
pointycastle ^1.0.1 1.0.2
Dev dependencies
flutter_test