Exemplo n.º 1
0
        public string Encrypt(string value)
        {
            System.Security.Cryptography.DES des = System.Security.Cryptography.DES.Create();
            byte[]           tmp = Encoding.UTF8.GetBytes(value);
            Byte[]           encryptoData;
            ICryptoTransform encryptor = des.CreateEncryptor(key, iv);

            using (MemoryStream memoryStream = new MemoryStream()) {
                using (var cs = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) {
                    using (StreamWriter writer = new StreamWriter(cs)) {
                        writer.Write(value);
                        writer.Flush();
                    }
                }
                encryptoData = memoryStream.ToArray();
            }
            des.Clear();
            return(Convert.ToBase64String(encryptoData));
        }