AES -256解密

时间:2012-10-11 10:01:24

标签: java aes

我有一个加密的电子邮件ID,用于取消订阅abcde.test.com。

代表:https://abcde.test.com/Forms/unSubscribe.jsp?n=2&rid=00028e7353d9c4eca480a579e10ef09b&eid=588876054d458e62779be9345f399252cac7346ad8c464b8ed0bdfbff3512dd96a5b4190c5d71c30c90c34ff39e544aa

这是在aes-256.where eid =“加密消息”中加密,当与keysize结合使用时加掉,而keystr(如“6a6b663472346c38736873346569727538346234333534376635333962353666”)形成编码密钥。

现在我要解密此消息。 任何人都可以帮我解密吗?

1 个答案:

答案 0 :(得分:0)

使用Java SE和Apache Commons尝试以下操作。请注意,您没有为密码指示模式或填充(仅“AES”),因此您可能需要进行一些调整。

// decode the key string into bytes (using Apache Commons)
byte[] keyBytes = Hex.decodeHex(keystr.toCharArray());

// create a representation of the key
SecretKeySpec spec = new SecretKeySpec(keyBytes, "AES");

// turn the key spec into a usable key
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("AES");
SecretKey key = keyFactory.generateSecret(spec);

// use a cipher to decrypt the eid
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] plainText = cipher.doFinal(hex.decodeHex(eid.toCharArray())); // decode from Hex again

我不知道eid代表什么类型,所以把它变成具体的东西取决于你,但这是一个例子:

String eid = new String(plainText, "ASCII");