标签:aes int private json password base64 publickey res base
//方法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);
标签:aes int private json password base64 publickey res base
原文地址:http://www.cnblogs.com/sj521/p/6773488.html