加密解密

Posted 纯粹的人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了加密解密相关的知识,希望对你有一定的参考价值。

//方法1 noToken
String input = "{\"userPassword\":\"12qwaszx\",\"userName\":\"15864516518\"}";
String resultData = Base64
.encodeBase64String(RSAUtils.encryptByPrivateKey(JSON.toJSONString(input).getBytes()));
System.out.println(resultData);
String reqData=new String(RSAUtils.decryptByPublicKey(Base64.decodeBase64(resultData)),"utf-8");
System.out.println(reqData);
//方法2 token
String input2 = "{\"userPassword\":\"12qwaszx\",\"userName\":\"15864516518\"}";
String resultData2 = new String(Base64.encodeBase64(AES.encrypt("199LP2Q03VKPG", input2)));
System.out.println("resultData2:"+resultData2);
String reqData2 = AES.decrypt("199LP2Q03VKPG", Base64.decodeBase64(resultData2));
System.out.println("reqData2:"+reqData2);

以上是关于加密解密的主要内容,如果未能解决你的问题,请参考以下文章

RSA 加密解密

JAVA加密解密要用到的JAR包

C# DES加密解密问题

敏感数据加密解密

C#中RSA加密解密

html加密解密代码