private string RSADecode(List <string> encodeRes, BigInt d, BigInt n) { var res = ""; foreach (var e in encodeRes) { var b = new BigInt(e); b = b.Pow(d); b = b % n; var index = Convert.ToInt32(b.ToString()); res += characters[index].ToString(); } return(res); }
private List <string> RSAEncode(string s, BigInt e, BigInt n) { var res = new List <string>(); var b = new BigInt(); for (var i = 0; i < s.Length; i++) { var index = Array.IndexOf(characters, s[i]); b = new BigInt(index.ToString()); b = b.Pow(e); b = b % n; res.Add(b.ToString()); } return(res); }
public void BigIntShouldPowCorrectly(string value, string power, string expected) { var result = BigInt.Pow(new BigInt(value), new BigInt(power)).ToString(); Assert.AreEqual(expected, result); }