-2
我必須解密使用.NET中的RSA xml簽名公鑰加密的字符串 我嘗試使用引發錯誤的php RSA加密模塊。因此,我想要使用Java。我是一個新的Java。示例代碼將非常有用。Java:使用RSA私鑰(Xml簽名)解密字符串
其實我需要移植此以下.NET代碼到Java
RSACryptoServiceProvider rsaCryptoServiceProvider = new RSACryptoServiceProvider(keySize);
rsaCryptoServiceProvider.FromXmlString(privateKey);
int base64BlockSize = ((keySize/8) % 3 != 0) ? (((keySize/8)/3) * 4) + 4 : ((keySize/8)/3) * 4;
int iterations = inputString.Length/base64BlockSize;
ArrayList arrayList = new ArrayList();
for (int i = 0; i < iterations; i++)
{
byte[] encryptedBytes = Convert.FromBase64String(inputString.Substring(base64BlockSize * i, base64BlockSize));
Array.Reverse(encryptedBytes);
arrayList.AddRange(rsaCryptoServiceProvider.Decrypt(encryptedBytes, false));
} lstrResponse = Encoding.UTF8.GetString(arrayList.ToArray(Type.GetType("System.Byte")) as byte[]);
你的意思'Cipher.getInstance()'? – 2012-07-27 00:34:03
謝謝,糾正它 – Arne 2012-07-27 04:16:14