Example #1
0
        public void Generate_输入正常的字符串_加密后字符串长度为32位()
        {
            //arrange
            string originalStr = "Test";

            //act
            string target = MD5Encrypt.Generate(originalStr);

            //assert
            Assert.IsTrue(target.Length == 32);
        }
Example #2
0
        public void Generate_输入两次同样的字符串_加密后的字符串相同()
        {
            //arrange
            string originalStr1 = "Test";
            string originalStr2 = "Test";

            //act
            string target1 = MD5Encrypt.Generate(originalStr1);
            string target2 = MD5Encrypt.Generate(originalStr2);

            //assert
            Assert.IsTrue(target1 == target2);
        }
Example #3
0
        static void Main(string[] args)
        {
            IEncrypt        enc1 = new MD5Encrypt();
            ICheckedEncrypt enc2 = new ECDEncrypt()
            {
                TestData = "Cozy最屌",
            };
            ICheckedEncrypt enc3 = new MD5InfoEncrypt()
            {
                Info = "Cozy最屌",
            };

            string str1 = enc1.Generate("Cozy");
            string str2 = enc2.Generate(null);
            string str3 = enc3.Generate(null);

            Console.WriteLine(str1);
            Console.WriteLine(str2);
            Console.WriteLine(str3);
            Console.WriteLine(enc2.Check(str2));
            Console.WriteLine(enc3.Check(str3));

            Console.ReadKey();
        }