私は以下の方法を持っています:
public String decrypt(String strToBeDecrypted) {
try {
strToBeDecrypted = URLDecoder.decode(strToBeDecrypted, "UTF-8");
DESKeySpec desKeySpec = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey skey = keyFactory.generateSecret(desKeySpec);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, skey, ivSpec);
byte[] keyByteArray = new BASE64Decoder().decodeBuffer(strToBeDecrypted);
byte[] original = cipher.doFinal(keyByteArray);
return new String(original, "UTF-8");
} catch (Exception e) {
logger.error(ExceptionUtil.getDetailedMessage(e));
}
return "";
}
これは投げてる
"name=javax.crypto.IllegalBlockSizeException;message=Input length must be multiple of 8 when decrypting with padded cipher;"
以下の行で:
byte[] original = cipher.doFinal(keyByteArray);
誰かがここで何が問題なのか教えてもらえますか?