Coder Social home page Coder Social logo

rsa-encrypt's Introduction

rsa-encrypt

测试加密(可以直接运行com.vector.AppTest)

String             d    = "I love you so much";
Map<String,Object> keys = RSAUtils.generateKeys(1024);
System.out.println("================生成签名如下============");
String s=RSAUtils.sign(d.getBytes(),RSAUtils.getPrivateKey(keys));
System.out.println(s);
System.out.println("================生成签名结束============END");
System.out.println("================公钥加密============");
byte[] bs = RSAUtils.encryptByPublicKey(d.getBytes(),RSAUtils.getPublicKey(keys));
System.out.println(new String(bs, StandardCharsets.UTF_8));
System.out.println("================公钥加密============END");
System.out.println("================私钥解密============");
byte[] d2 = RSAUtils.decryptByPrivateKey(bs,RSAUtils.getPrivateKey(keys));
System.out.println(new String(d2,StandardCharsets.UTF_8));
System.out.println("================私钥解密============END");
System.out.println("================签名验证============");
System.out.println(RSAUtils.verify(d.getBytes(),RSAUtils.getPublicKey(keys),s));
System.out.println("================签名验证============END");

#测试结果


RAS 加密测试现在开始
================生成签名如下============
fC+COD0YA6CQlyPWrB0APVif5zMXo+y7QTPrYhTsnH66y/rUt2NojEMB0/ot39AOAJfbcsB3ahYPPr+8u1cNdK8DtxeXGwjCeAbLMKy6sKqtH3f9tMHoC4125nvAxfPrZRjH+N23Aa52gcD5hWXHpdncz/zxqrzkv3J6XDqAoMc=
================生成签名结束============END
================公钥加密============
D�P�*�~	�r�-�����/OL��>em-��A.M
================公钥加密============END
================私钥解密============
I love you so much
================私钥解密============END
================签名验证============
true
================签名验证============END
RAS 加密测试已经结束了

Process finished with exit code 0

rsa-encrypt's People

Contributors

cyancicada avatar

Watchers

James Cloos avatar

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.