日期:2014-05-20  浏览次数:20754 次

java如何调用c#生成的公钥加密数据?
如题,对加密不熟悉,谢谢高手解答。
c#生成的公钥:
<RSAKeyValue><Modulus>ya1XxKmTpd6khecpMkZ7Q2TWZtHQHBpdBVtVTxSUyzYievhj2skyDq5o7Jauc5hozd2Em+xs+CZBiXdOfS/RTwz7FxZy0D52G9dZKFCZ45YrF2azGK9qiMR+hyOUfJganvgSNsMYOvELhYMQm2CugvZaPlER9B59qlwx9T5Xysk=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>
用上面一段东西对一个字符串加密,然后返回一个字符串
一点头绪有没有,这格式好像跟java的完全不同,请问高手这样该如何加密啊?谢谢


------解决方案--------------------
public static BigInteger[] encodeRSA(byte testoChiaroInBlocchi[][], BigInteger N, BigInteger key, boolean[] bNegtiveNum)
{
BigInteger testoCriptato[] = new BigInteger[testoChiaroInBlocchi.length];
 // System.out.println("加密前分组数据:");
for(int i = 0; i < testoChiaroInBlocchi.length; i++)
{
testoCriptato[i] = new BigInteger(testoChiaroInBlocchi[i]);
if (testoCriptato[i].compareTo(BigInteger.ZERO) < 0) {
bNegtiveNum[i] = true;
 // System.out.println(i+":"+testoCriptato[i].toString());
}
testoCriptato[i] = testoCriptato[i].modPow(key, N);
}

return testoCriptato;
}