Ejemplo n.º 1
0
        public void TestRevEnc()
        {
            //可逆加密
            //des
            string desEncode = DEncryptUtils.DESEncrypt(txt, key);

            Console.WriteLine("des加密值:" + desEncode);
            Assert.AreEqual(txt, DEncryptUtils.DESDecrypt(desEncode, key));

            //aes
            string aesEncode = DEncryptUtils.AESEncrypt(txt);

            Console.WriteLine("aes加密值:" + aesEncode);
            Assert.AreEqual(txt, DEncryptUtils.AESDecrypt(aesEncode));

            //base64
            string base64Encode = DEncryptUtils.Base64Encrypt(txt);

            Console.WriteLine("base64加密值:" + aesEncode);
            Assert.AreEqual(txt, DEncryptUtils.Base64Decrypt(base64Encode));

            //xor
            string xor = DEncryptUtils.GetXORCode(txt, key);

            Console.WriteLine("xor加密值:" + xor);
            Assert.AreEqual(txt, DEncryptUtils.GetXORCode(xor, key));
        }