-2
私は、JavaでRSAの暗号化と復号化関数を書こうとしていますが、いくつかの問題があります:BigIntegerとbyte []またはviceversaとの間の変換が、RSA in Java:BitIntegerとbyte []
public byte[] encrypt(byte[] message, BigInteger n, BigInteger e) {
BigInteger m = new BigInteger(1, message);
BigInteger c = m.modPow(e, n);
return c.toByteArray();
}
public byte[] decrypt(byte[] cipher, BigInteger n, BigInteger d) {
BigInteger c = new BigInteger(1, cipher);
BigInteger m = c.modPow(d, n);
return m.toByteArray();
}
ありがとうございます!
「問題があります。うん、あなたは何がうまくいかないのかという問題を抱えています。 –
申し訳ありませんが、本当のようです。復号化された配列は、メッセージ配列と同じではありません。つまり、暗号化と復号化の後のバイト配列は、メッセージ配列よりもずっと小さくなります(約14,000対274エントリ...)。 – gabse15
まあ、それは私のために働く。 –