Modified Rsa class
This commit is contained in:
parent
08af5df15b
commit
857aaabc40
@ -18,12 +18,18 @@ public class Rsa {
|
||||
d = e.modInverse(m);
|
||||
}
|
||||
|
||||
public Rsa(BigInteger e, BigInteger d, BigInteger n) {
|
||||
this.e = e;
|
||||
this.d = d;
|
||||
this.n = n;
|
||||
}
|
||||
|
||||
private static BigInteger generatePrime(int numberOfBytes) {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
return new BigInteger(numberOfBytes, 100, secureRandom).nextProbablePrime();
|
||||
}
|
||||
|
||||
public BigInteger encrypt(String message) {
|
||||
public BigInteger encrypt(String message, BigInteger e, BigInteger n) {
|
||||
BigInteger plaintext = toHex(message);
|
||||
return plaintext.modPow(e, n);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user