我有一个加密的电子邮件ID,用于取消订阅abcde.test.com。
这是在aes-256.where eid =“加密消息”中加密,当与keysize结合使用时加掉,而keystr(如“6a6b663472346c38736873346569727538346234333534376635333962353666”)形成编码密钥。
现在我要解密此消息。 任何人都可以帮我解密吗?
答案 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");