// Convert a big integer to a base 64 string private string bigint_to_b64(BigInteger bi) { byte[] b = bi.getBytes(); return Convert.ToBase64String(b); }
// Perform an RSA public key operation on input public byte[] DoPublic(byte[] input) { if (input.Length != this.keylen) throw new ArgumentException("input.Length does not match keylen"); if (ReferenceEquals(this.N, null)) throw new ArgumentException("no key set!"); BigInteger T = new BigInteger(input); if (T >= this.N) throw new ArgumentException("input exceeds modulus"); T = T.modPow(this.E, this.N); byte[] b = T.getBytes(); return pad_bytes(b, this.keylen); }