我写了一个休息服务来加密和解密 URL。
加密代码:
@GET
@Produces("application/json")
@Path("/encrypt/")
public Response encryptWithQuery(@QueryParam("plainString") String plainString)
throws JSONException {
Response response = new Response();
AesUtil util = new AesUtil(KEY_SIZE, ITERATION_COUNT);
response = util.encrypt(SALT, IV, PASSPHRASE, plainString);
return response;
}
解密代码:
@GET
@Produces("application/json")
@Path("/decryptWP/")
public Response decryptWithQuery(@QueryParam("encryptString") String encryptString)
throws JSONException {
Response response = new Response();
AesUtil util = new AesUtil(KEY_SIZE, ITERATION_COUNT);
response = util.decrypt(SALT, IV, PASSPHRASE, encryptString);
return response;
}
当我调用我的加密休息服务时,我得到了加密的字符串
用于加密的 url
http://localhost:9080/kttafm/keybank/encrypt?plainString=http://localhost:9080/kttafm/master.jsp?abc=zyx
但是当我调用解密休息服务时,我得到以下异常
javax.crypto.BadPaddingException: Given final block not properly padded
但是如果我从@Queryparam tp @path 参数移动,解密工作正常,
可以正常工作并解密加密字符串的解密方法是
@GET
@Produces("application/json")
@Path("/decrypt/{encryptString}")
public Response decrypt(@PathParam("encryptString") String encryptString)
throws JSONException {
Response response = new Response();
AesUtil util = new AesUtil(KEY_SIZE, ITERATION_COUNT);
response = util.decrypt(SALT, IV, PASSPHRASE, encryptString);
return response;
}
我错过了什么?