Exemple #1
0
        public void BigIntShouldSubtractBySumCorrectly(string first, string second,
                                                       string expected)
        {
            var sum = new BigInt(first) + new BigInt(second);

            Assert.AreEqual(expected, sum.ToString());
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void BigIntOverLongShouldSumCorrectly(long a, long b, string expected)
        {
            var actual = new BigInt(a.ToString()) + new BigInt(b.ToString());

            Assert.AreEqual(expected, actual.ToString());
        }
Exemple #5
0
        public void BigIntShouldGetRightToString(long value)
        {
            var integer = new BigInt(value.ToString());

            Assert.AreEqual(value.ToString(), integer.ToString());
        }
Exemple #6
0
        public void BigIntToStringCorrectly(string value)
        {
            var integer = new BigInt(value);

            Assert.AreEqual(value, integer.ToString());
        }
Exemple #7
0
        public void BigIntShouldDivCorrectly(string first, string second, string expected)
        {
            var div = new BigInt(first) / new BigInt(second);

            Assert.AreEqual(expected, div.ToString());
        }
Exemple #8
0
        public void BigIntShouldSubtractCorrectly(string first, string second, string expected)
        {
            var sub = new BigInt(first) - new BigInt(second);

            Assert.AreEqual(sub.ToString(), expected);
        }