XML AES解密JAVA [英] XML AES decryption JAVA
本文介绍了XML AES解密JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我使用C#RijndaelManaged类使用128位AES加密了xml。我硬编码了IV和密钥字节。我加密的XML看起来像这样。
Hi everyone
I have encrypted an xml using 128 bit AES using C# "RijndaelManaged" Class. I hardcoded the IV and key bytes. My encrypted XML looks like this.
<?xml version="1.0" standalone="yes"?>
<Data>
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc" />
<CipherData>
<CipherValue>ZW97bGRnZHljagIZZV0Ifq160IptZMvv</CipherValue>
</CipherData>
</EncryptedData>
</Data>
有谁能告诉我解密这个的java代码...
我已经尝试了几个网但是到目前为止我没有成功..请帮忙!
我想我被困在Java代码中:
Can anyone tell me the java code to decrypt this...
I have tried a few from net but I have not been successful so far.. Please help!
I think I am stuck here in Java Code:
NodeList list = doc.getElementsByTagName("EncryptedData");
Element node = (Element)list.item(0);
String val = node.getNodeValue();
//create the decryption context
DOMDecryptContext dctx = new DOMDecryptContext(keys, node);
//unmarshal encrypted data
EncryptedData encdata = (EncryptedData)fac.unmarshalEncryptedType(dctx);
javax.crypto.spec.IvParameterSpec ivspec = new javax.crypto.spec.IvParameterSpec(ivbyte);
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, keys, ivspec);
byte[] bytes = encdata.getEncoding().getBytes();
byte[] decrypted = cipher.doFinal(node.); //Stuck here... No idea what to pass here
String str = new String(decrypted);
推荐答案
http:// www.java2s.com/Code/Java/Security/EncryptionanddecryptionwithAESECBPKCS7Padding.htm [ ^ ]。
这篇关于XML AES解密JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文