Exemple #1
0
        public void Sm2TestUtilKeyTest()
        {
            Tuple <string, string> key = Sm2TestUtil.CreateKeyPair();

            Console.WriteLine("公钥是:{0}", key.Item1);
            Console.WriteLine("密钥是:{0}", key.Item2);
        }
Exemple #2
0
        public void Sm2TestUtilKeyNoCompressTest()
        {
            Tuple <string, string> key = Sm2TestUtil.CreateKeyPair(false);

            Console.WriteLine("公钥是:{0}", key.Item1);
            Console.WriteLine("密钥是:{0}", key.Item2);
            Assert.AreEqual("04", key.Item1.Substring(0, 2));
        }
Exemple #3
0
        public void Sm2TestUtilEncryptTest()
        {
            string publicKey = "02a02cee0eabf72d073b00f3685e120058ce983ad482d85f659e30779ce26b6dcb";
            string plainText = string.Join(",", Enumerable.Repeat(Guid.NewGuid(), 10000));
            string cipher    = Sm2TestUtil.Encrypt(publicKey, plainText);

            Console.WriteLine(cipher);

            string primaryKey = "008125e15f2961d94876c1e8bccf0b14de6c2e8eda390a50d00e4999d25cdcdee2";
            string content    = Sm2TestUtil.Decrypt(primaryKey, cipher);

            Console.WriteLine(content);

            Assert.AreEqual(content, plainText);
        }