public static BigInt[] Encode(string text, BigInt e, BigInt n) { var result = new List <BigInt>(); foreach (var symbol in text) { var message = BigInt.ModPow(new BigInt(symbol), e, n); result.Add(message); } return(result.ToArray()); }
public static string Decode(BigInt[] message, BigInt d, BigInt n) { var text = new StringBuilder(); foreach (var b in message) { var symbol = BigInt.TryToInt(BigInt.ModPow(b, d, n)); text.Append((char)symbol); } return(text.ToString()); }