首页 > 代码库 > 加密解密
加密解密
//方法1 noToken
String input = "{\"userPassword\":\"12qwaszx\",\"userName\":\"15864516518\"}";
String resultData = http://www.mamicode.com/Base64
.encodeBase64String(RSAUtils.encryptByPrivateKey(JSON.toJSONString(input).getBytes()));
System.out.println(resultData);
String reqData=http://www.mamicode.com/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);
加密解密