Coder Social home page Coder Social logo

chenxing640 / dart_crypto Goto Github PK

View Code? Open in Web Editor NEW
35.0 2.0 8.0 251 KB

集成了Base64, 32/16 Bits MD5, AES, RSA等算法(This integrates Base64, 32/16 Bits MD5, AES and RSA algorithms.)。

Home Page: https://www.jianshu.com/p/d6db6c6d81d8

License: Other

Java 0.37% Ruby 2.14% Objective-C 0.76% Dart 96.72%
flutter dart algorithm aes rsa md5 base64 des

dart_crypto's Introduction

如果能帮助到你,就请你给一颗star,谢谢!(If this can help you, please give it a star, thanks!)

License MIT  Support 

dart_crypto

集成了Base64, 32/16 Bits MD5, AES, RSA等算法(This integrates Base64, 32/16 Bits MD5, AES and RSA algorithms.)。

Group(ID:155353383)

Recommendation

Getting Started

For help getting started with Flutter, view the online

Usage

Plain Text

final plainText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit ........。本文基本上是将dart官网部分内容进行翻译,没兴趣的请出门左转至Dart的官网,有兴趣的同志请继续阅读本文。Flutter教程在这里通常,映射是一个有键和值的对象。 键和值都可以是任何类型的对象。 每个键只出现一次,但您可以多次使用相同的值。Dart的Map支持由映射文字和Map。int和double都是num的子类型。 num类型包括基本运算符,如+, - ,/和*,也是你可以找到abs(),ceil()和floor()以及其他方法的地方。 (按位运算符,如>>,在int类中有定义。)如果num及其子类没有您要想要内容,那dart:math库可能有您想要的。Dart字符串是一系列UTF-16代码单元。 您可以使用单引号或双引号来创建字符串:您可以使用{expression}将表达式的值放在字符串中。如果表达式是标识符,则可以跳过{}。 要获取对应于对象的字符串,Dart调用对象的toString()方法。为了表示布尔值,Dart有一个名为bool的类型。 只有两个对象具有bool类型:true和false,它们都是编译时常量。Dart的类型安全意味着您不能使用if(nonbooleanValue)或assert(nonbooleanValue)等代码。 相反,明确检查值,如下所示:也许几乎每种编程语言中最常见的集合是数组或有序的对象组。 在Dart中,数组是List对象,因此大多数人只是将它们称为列表。Dart列表文字看起来像JavaScript数组文字。 这是一个简单的Dart List:";

Base64

try {
    // Base64 - Encode
    final base64Encoded = crypto.DYFCryptoProvider.yf_base64Encode(plainText);
    print("[Base64] encode: " + base64Encoded);

    // Base64 - Dncode
    final base64Decoded = crypto.DYFCryptoProvider.yf_base64Decode(base64Encoded);
    print("[Base64] decode: " + base64Decoded);
} catch (e) {
    print("e: $e");
}

MD5

try {
    // MD5 - 32 Bits Encode
    final md5Hash = crypto.DYFCryptoProvider.md5Encode(plainText);
    print("[MD5] Hash: " + md5Hash);

    // MD5 - 16 Bits Encode
    final md5b16hash = crypto.DYFCryptoProvider.bit16md5Enconde(plainText);
    print("[MD5] 16 Bits Hash: " + md5b16hash);
} catch (e) {
    print("e: $e");
}

AES

try {
    // AES Key
    // final aesKey = "smMQI8dMK2nOMUR0TdpBYQUnLpbW8kjHrdy86WtU6eB1Ff6mYveYzezopmbjwBZEjPQmg";
    final aesKey = "smMQI8dMK2";
    print("[AES] key: " + aesKey);

    // AES - Encrypt
    String aesEncryptedText = crypto.DYFCryptoProvider.aesEncrypt(plainText, aesKey);
    print("[AES] encryptedText: " + aesEncryptedText);

    // AES - Decrypt
    String aesDecryptedText = crypto.DYFCryptoProvider.aesDecrypt(aesEncryptedText, aesKey);
    print("[AES] decryptedText: " + aesDecryptedText);
} catch (e) {
    print("e: $e");
}

RSA

// 公钥
final publicKey =
"""MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCmPW2SwJFldGVB1SM82VYvSZYR
F1H5DREUiDK2SLnksxHAV/roC1uB44a4siUehJ9AKeV/g58pVrjhX3eSiBh9Khom
/S2hEWF2n/6+lqqiwQi1W5rjl86v+dI2F6NgbPFpfesrRjWD9uskT2VX/ZJuMRLz
8VPIyQOM9TW3PkMYBQIDAQAB""";

// 私钥 (pkcs8)
final privateKey =
"""MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKY9bZLAkWV0ZUHV
IzzZVi9JlhEXUfkNERSIMrZIueSzEcBX+ugLW4HjhriyJR6En0Ap5X+DnylWuOFf
d5KIGH0qGib9LaERYXaf/r6WqqLBCLVbmuOXzq/50jYXo2Bs8Wl96ytGNYP26yRP
ZVf9km4xEvPxU8jJA4z1Nbc+QxgFAgMBAAECgYArZVW5PXO3HE9ihBUSyVlqNrdp
9sB7VyHiTjuOwiVkwiocH9trv6s/mPmONVLjSJOZ2FYEl4Nw8yaIDrfUFJrvhdbh
HJnwkO27Wo5jEfm2qGCwgQNtUACoIH637LXfP81v5I7eZtEa7kfO8Axpp3czvO1H
dIAlOI8rU4jb3fB1cQJBANLgfHd/CDro1gtvTrUeTw/lqsKVScGiHn+pmT+THed6
ftJ2MAJVcL/0H8+fFN5mRypCL7LQyPO48dTmfY9PbocCQQDJz8xZGq2BNAd3gSrN
i3q++SEyjRPzDfr8AGJBJF8qtslcSYrVB/jjPx/qNNlMxOoXnpozBojzVTO3UirM
J/wTAkEAzb930YOhPREGHnwImFCtJT6ZYGcWYpXSGg8Y1d2tlLeA28myx+QjMTZ4
fzOgwemaz9FqBpcNKjctxOLqaRRAKwJAXPZwznbgh8zcx6rjea2PjFscdLnR/7tn
6x+OIy3K/NUYan+iCUHT33JblDpmAtwObXTs2SZgfZ645PBfsI2WqwJAGJxnG8+w
iCnzN0CIZvG96tfOZmz0lkM4NSHDwdCSbagJlZccOtodpn00Dzy+l0t+oFe0Xm3R
A0WkPzQX/seO0Q==""";
try {
    // RSA - Encrypt
    String rsaEncryptedText = crypto.DYFCryptoProvider.rsaEncrypt(plainText, publicKey);
    print("[rsa] encryptedText: " + rsaEncryptedText);

    // RSA - Decrypt
    String rsaDecryptedText = crypto.DYFCryptoProvider.rsaDecrypt(rsaEncryptedText, privateKey);
    print("[rsa] decryptedText: " + rsaDecryptedText);

    // RSA - Sign
    String signature = crypto.DYFCryptoProvider.rsaSign(plainText, privateKey);
    print("[rsa] signature: " + signature);

    // RSA - Verify
    bool ret = crypto.DYFCryptoProvider.rsaVerify(signature, plainText, publicKey);
    print("[rsa] signature verification: " + ret.toString());
} catch (e) {
    print("e: $e");
}

Feedback is welcome

If you notice any issue, please create an issue. I will be happy to help you.

dart_crypto's People

Contributors

chenxing640 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dart_crypto's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.