CreateDecryptor() 공개 메소드

public CreateDecryptor ( ) : ICryptoTransform
리턴 ICryptoTransform
예제 #1
0
        internal static byte[] TripleDESKeyWrapDecrypt (byte[] rgbKey, byte[] rgbEncryptedWrappedKeyData) {
            // Check to see whether the length of the encrypted key is reasonable
            if (rgbEncryptedWrappedKeyData.Length != 32 && rgbEncryptedWrappedKeyData.Length != 40 
                && rgbEncryptedWrappedKeyData.Length != 48) 
                throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_KW_BadKeySize"));

            TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
            // Assume no padding, use CBC mode
            tripleDES.Padding = PaddingMode.None;
            ICryptoTransform dec1 = tripleDES.CreateDecryptor(rgbKey, s_rgbTripleDES_KW_IV);
            byte[] temp2 = dec1.TransformFinalBlock(rgbEncryptedWrappedKeyData, 0, rgbEncryptedWrappedKeyData.Length);
            Array.Reverse(temp2);
            // Get the IV and temp1
            byte[] rgbIV = new byte[8];
            Buffer.BlockCopy(temp2, 0, rgbIV, 0, 8);
            byte[] temp1 = new byte[temp2.Length - rgbIV.Length];
            Buffer.BlockCopy(temp2, 8, temp1, 0, temp1.Length);

            ICryptoTransform dec2 = tripleDES.CreateDecryptor(rgbKey, rgbIV);
            byte[] rgbWKCKS = dec2.TransformFinalBlock(temp1, 0, temp1.Length);

            // checksum the key
            byte[] rgbWrappedKeyData = new byte[rgbWKCKS.Length - 8];
            Buffer.BlockCopy(rgbWKCKS, 0, rgbWrappedKeyData, 0, rgbWrappedKeyData.Length);
            SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
            byte[] rgbCKS = sha.ComputeHash(rgbWrappedKeyData);
            for (int index = rgbWrappedKeyData.Length, index1 = 0; index < rgbWKCKS.Length; index++, index1++)
                if (rgbWKCKS[index] != rgbCKS[index1])
                    throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_BadWrappedKeySize"));
            return rgbWrappedKeyData;
        }
        internal static string DesEncriptar(string clave)
        {
            String sPass = String.Empty;
            try
            {
                string key = "ABCDEFG54669525PQRSTUVWXYZabcdef852846opqrstuvwxyz";
                byte[] keyArray;

                byte[] Array_a_Descifrar = Convert.FromBase64String(clave);

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();

                keyArray = hashmd5.ComputeHash(
                UTF8Encoding.UTF8.GetBytes(key));

                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(Array_a_Descifrar, 0, Array_a_Descifrar.Length);
                tdes.Clear();
                sPass = UTF8Encoding.UTF8.GetString(resultArray);
            }
            catch (Exception) {}
            return sPass;
        }
예제 #3
0
        internal string Decrypt(string value)
        {
            MD5CryptoServiceProvider hashProvider = null;
            TripleDESCryptoServiceProvider provider = null;

            try
            {
                hashProvider = new MD5CryptoServiceProvider();
                var hashPassPhrase = hashProvider.ComputeHash(Encoding.UTF8.GetBytes(passPhrase));

                provider = new TripleDESCryptoServiceProvider();
                provider.Key = hashPassPhrase;
                provider.Mode = CipherMode.ECB;
                provider.Padding = PaddingMode.PKCS7;

                var dataToEncrypt = Convert.FromBase64String(value);
                var decryptor = provider.CreateDecryptor();
                var results = decryptor.TransformFinalBlock(dataToEncrypt, 0, dataToEncrypt.Length);
                return Encoding.UTF8.GetString(results);

            }
            finally
            {
                if (provider != null) provider.Clear();
                if (hashProvider != null) hashProvider.Clear();
            }
        }
예제 #4
0
        public static string Decodificar(string entrada)
        {
            TripleDESCryptoServiceProvider tripledescryptoserviceprovider = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider md5cryptoserviceprovider = new MD5CryptoServiceProvider();

            try
            {
                if (entrada.Trim() != "")
                {
                    string chave = "asdfg";
                    tripledescryptoserviceprovider.Key = md5cryptoserviceprovider.ComputeHash(Encoding.Default.GetBytes(chave));
                    tripledescryptoserviceprovider.Mode = CipherMode.ECB;
                    ICryptoTransform desdencrypt = tripledescryptoserviceprovider.CreateDecryptor();
                    byte[] buff = Convert.FromBase64String(entrada);

                    return Encoding.Default.GetString(desdencrypt.TransformFinalBlock(buff, 0, buff.Length));
                }
                else
                {
                    return "";
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Erro" + exception.Message);
                throw exception;
            }
            finally
            {
                tripledescryptoserviceprovider = null;
                md5cryptoserviceprovider = null;
            }
        }
예제 #5
0
        //Decryption Method

        public string DecryptTripleDES(string base64Text)
        {
            try
            {
                string Key    = Convert.ToString(configuration.GetSection("appSettings").GetSection("EncryptKey").Value);
                byte[] Buffer = new byte[0];

                System.Security.Cryptography.TripleDESCryptoServiceProvider DES = new System.Security.Cryptography.TripleDESCryptoServiceProvider();

                System.Security.Cryptography.MD5CryptoServiceProvider hashMD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

                DES.Key = hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(Key));

                DES.Mode = System.Security.Cryptography.CipherMode.ECB;

                System.Security.Cryptography.ICryptoTransform DESDecrypt = DES.CreateDecryptor();

                Buffer = Convert.FromBase64String(base64Text);

                string DecTripleDES = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));

                return(DecTripleDES);
            }
            catch (Exception)
            {
                return(string.Empty);
            }
        }
        /// <summary>
        /// DeCrypt a string using dual encryption method. Return a DeCrypted clear string
        /// </summary>
        /// <param name="cipherString">encrypted string</param>
        /// <param name="useHashing">Did you use hashing to encrypt this data? pass true is yes</param>
        /// <returns></returns>
        public string Decrypt(string cipherString, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = Convert.FromBase64String(cipherString);


            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(Encoding.UTF8.GetBytes(SecurityKey));
                hashmd5.Clear();
            }
            else
                keyArray = Encoding.UTF8.GetBytes(SecurityKey);

            var tdes = new TripleDESCryptoServiceProvider
            {
                Key = keyArray,
                Mode = CipherMode.ECB,
                Padding = PaddingMode.PKCS7
            };

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();
            return Encoding.UTF8.GetString(resultArray);
        }
예제 #7
0
        /// <summary>
        /// Ghi license ra file
        /// </summary>
        /// <param name="FilePath"></param>
        /// <returns></returns>
        public static string ReadFile(string FilePath)
        {
            try
            {
                FileInfo fi = new FileInfo(FilePath);
                if (fi.Exists == false)
                    return string.Empty;

                FileStream fin = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
                TripleDES tdes = new TripleDESCryptoServiceProvider();
                CryptoStream cs = new CryptoStream(fin, tdes.CreateDecryptor(key, iv), CryptoStreamMode.Read);

                StringBuilder SB = new StringBuilder();
                int ch;
                for (int i = 0; i < fin.Length; i++)
                {
                    ch = cs.ReadByte();
                    if (ch == 0)
                        break;
                    SB.Append(Convert.ToChar(ch));
                }

                cs.Close();
                fin.Close();
                return SB.ToString();
            }
            catch(Exception ex)
            {
                return "";
            }
        }
예제 #8
0
        /// <summary>
        /// Décrypte une chaine cryptée à partir d'un chiffreur symétrique
        /// </summary>
        /// <param name="base64String">chaine cryptée</param>
        /// <param name="pass">Mot de passe utilisé pour dériver la clé</param>
        /// <returns>Chaine décryptée</returns>
        private static string Decrypt(string base64String, string pass)
        {
            string result = string.Empty;

            System.Security.Cryptography.TripleDESCryptoServiceProvider des =
                new System.Security.Cryptography.TripleDESCryptoServiceProvider();
            des.IV = new byte[8];
            System.Security.Cryptography.PasswordDeriveBytes pdb =
                new System.Security.Cryptography.PasswordDeriveBytes(pass, new byte[0]);
            des.Key = pdb.CryptDeriveKey("RC2", "SHA1", 128, new byte[8]);
            byte[] encryptedBytes = Convert.FromBase64String(base64String);

            using (MemoryStream ms = new MemoryStream(base64String.Length))
            {
                using (System.Security.Cryptography.CryptoStream decStream =
                           new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(),
                                                                         System.Security.Cryptography.CryptoStreamMode.Write))
                {
                    decStream.Write(encryptedBytes, 0, encryptedBytes.Length);
                    decStream.FlushFinalBlock();
                    byte[] plainBytes = new byte[ms.Length];
                    ms.Position = 0;
                    ms.Read(plainBytes, 0, (int)ms.Length);
                    result = Encoding.UTF8.GetString(plainBytes);
                }
            }
            return(result);
        }
예제 #9
0
        /// <summary>
        /// A chave deve possuir 16 com caracteres "1234567890123456"
        /// </summary>
        /// <param name="str"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetDescriptografiaSimetrica(this string str, string key)
        {
            using (TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider())
            {


                provider.Mode = CipherMode.CFB;
                provider.Padding = PaddingMode.PKCS7;
                byte[] inputEquivalent = Convert.FromBase64String(str);

                MemoryStream msDecrypt = new MemoryStream();

                CryptoStream csDecrypt = new CryptoStream(msDecrypt, provider.CreateDecryptor(Encoding.UTF8.GetBytes(key), new byte[] { 138, 154, 251, 188, 64, 108, 167, 121 }), CryptoStreamMode.Write);
                csDecrypt.Write(inputEquivalent, 0, inputEquivalent.Length);
                csDecrypt.FlushFinalBlock();

                csDecrypt.Close();

                str = Encoding.UTF8.GetString(msDecrypt.ToArray());
                msDecrypt.Close();
            }


            return str;
        }
예제 #10
0
 public static string Decrypt(string cypherString, bool useHasing)
 {
     byte[] keyArray;
     byte[] toDecryptArray = Convert.FromBase64String(cypherString);
     string key = "uzma";
     if (useHasing)
     {
         MD5CryptoServiceProvider hashmd = new MD5CryptoServiceProvider();
         keyArray = hashmd.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
         hashmd.Clear();
     }
     else
     {
         keyArray = UTF8Encoding.UTF8.GetBytes(key);
     }
     TripleDESCryptoServiceProvider tDes = new TripleDESCryptoServiceProvider();
     tDes.Key = keyArray;
     tDes.Mode = CipherMode.ECB;
     tDes.Padding = PaddingMode.PKCS7;
     ICryptoTransform cTransform = tDes.CreateDecryptor();
     try
     {
         byte[] resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length);
         tDes.Clear();
         return UTF8Encoding.UTF8.GetString(resultArray, 0, resultArray.Length);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
파일: Text.cs 프로젝트: sameesh-s/stego-app
        /// <summary>
        /// Decrypt the given string using the specified key.
        /// </summary>
        /// <param name="strEncrypted">The string to be decrypted.</param>
        /// <param name="key">The decryption key.</param>
        /// <returns>The decrypted string.</returns>
        /// <exception cref="Exception">Unexpected Exception</exception>
        public static string Decrypt(string strEncrypted, string key)
        {
            try
            {
                TripleDESCryptoServiceProvider decrypto = new TripleDESCryptoServiceProvider();
                MD5CryptoServiceProvider hash = new MD5CryptoServiceProvider();

                byte[] byteHash, byteBuff;

                string tempKey = key;

                byteHash = hash.ComputeHash(ASCIIEncoding.ASCII.GetBytes(tempKey));

                hash = null;

                decrypto.Key = byteHash;
                decrypto.Mode = CipherMode.ECB; //CBC, CFB

                byteBuff = Convert.FromBase64String(strEncrypted);

                string strDecrypted = ASCIIEncoding.ASCII.GetString(decrypto.CreateDecryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));
                decrypto = null;

                return strDecrypted;
            }
            catch (Exception ex)
            {
                throw new Exception("Error: " + ex.Message + ".\n Decryption Failed. Please start over..!");
            }
        }
예제 #12
0
        public static string DecryptString(string message)
        {
            byte[] results;

            // Step 1. We hash the customPassPhrase using MD5
            // We use the MD5 hash generator as the result is a 128 bit byte array
            // which is a valid length for the TripleDES encoder we use below
            var hashProvider = new MD5CryptoServiceProvider();
            byte[] TDESKey = hashProvider.ComputeHash(Encoding.UTF8.GetBytes(customPassPhrase));

            // Step 3. Setup the decoder
            var tripleDESAlgorithm = new TripleDESCryptoServiceProvider() { Mode = CipherMode.ECB, Padding = PaddingMode.PKCS7 };
            tripleDESAlgorithm.Key = TDESKey;

            // Step 4. Convert the input string to a byte[]
            byte[] dataToDecrypt = Convert.FromBase64String(message);

            // Step 5. Attempt to decrypt the string
            try
            {
                ICryptoTransform decryptor = tripleDESAlgorithm.CreateDecryptor();
                results = decryptor.TransformFinalBlock(dataToDecrypt, 0, dataToDecrypt.Length);
                decryptor.Dispose();
            }
            finally
            {
                // Clear the TripleDes and Hashprovider services of any sensitive information
                tripleDESAlgorithm.Clear();
                hashProvider.Clear();
            }

            // Step 6. Return the decrypted string in UTF8 format
            return Encoding.UTF8.GetString(results);
        }
예제 #13
0
 public static string Decrypt(string cipherText, string passPhrase)
 {
     try
     {
         TripleDESCryptoServiceProvider objDESCrypto =
             new TripleDESCryptoServiceProvider();
         MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();
         byte[] byteHash, byteBuff;
         string strTempKey = passPhrase;
         byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));
         objHashMD5 = null;
         objDESCrypto.Key = byteHash;
         objDESCrypto.Mode = CipherMode.ECB; //CBC, CFB
         byteBuff = Convert.FromBase64String(cipherText);
         string strDecrypted = ASCIIEncoding.ASCII.GetString
         (objDESCrypto.CreateDecryptor().TransformFinalBlock
         (byteBuff, 0, byteBuff.Length));
         objDESCrypto = null;
         return strDecrypted;
     }
     catch (Exception ex)
     {
         return null;
     }
 }
예제 #14
0
        public static String Decrypt(string encryptedString)
        {
            string decyprted = null;
            byte[] inputBytes = null;

            try
            {
                inputBytes = Convert.FromBase64String(encryptedString);
                byte[] pwdhash = null;
                MD5CryptoServiceProvider hashmd5;

                //generate an MD5 hash from the password.
                //a hash is a one way encryption meaning once you generate
                //the hash, you cant derive the password back from it.
                hashmd5 = new MD5CryptoServiceProvider();
                pwdhash = hashmd5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
                hashmd5 = null;

                // Create a new TripleDES service provider
                TripleDESCryptoServiceProvider tdesProvider = new TripleDESCryptoServiceProvider();
                tdesProvider.Key = pwdhash;
                tdesProvider.Mode = CipherMode.ECB;

                decyprted = ASCIIEncoding.ASCII.GetString(
                    tdesProvider.CreateDecryptor().TransformFinalBlock(inputBytes, 0, inputBytes.Length));
            }
            catch(Exception e)
            {
                string str = e.Message;
                throw ;
            }
            return decyprted;
        }
예제 #15
0
        /// <summary>
        /// DeCrypt a string using dual encryption method. Return a DeCrypted clear string
        /// </summary>
        /// <param name="cipherString">encrypted string</param>
        /// <param name="useHashing">Did you use hashing to encrypt this data? pass true is yes</param>
        /// <returns></returns>
        public static string Decrypt(string cipherString, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = Convert.FromBase64String(cipherString);

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = SecurityKey;

            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                keyArray = UTF8Encoding.UTF8.GetBytes(key);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();
            return UTF8Encoding.UTF8.GetString(resultArray);
        }
예제 #16
0
        /// <summary>
        /// DeCrypt a string using dual encryption method. Return a DeCrypted clear string
        /// </summary>
        /// <param name="cipherString">encrypted string</param>
        /// <param name="useHashing">Did you use hashing to encrypt this data? pass true is yes</param>
        /// <returns></returns>
        public static string Decrypt(string cipherString)
        {
            byte[] keyArray;
            bool useHashing = true;
            byte[] toEncryptArray = Convert.FromBase64String(cipherString);
            string key = "ImgONE";
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                keyArray = UTF8Encoding.UTF8.GetBytes(key);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();
            return UTF8Encoding.UTF8.GetString(resultArray);
        }
예제 #17
0
        /// <summary>
        /// Decrypts a cipher sting
        /// </summary>
        /// <param name="cipherString">String to decrypt</param>
        /// <returns>Decrypted string</returns>
        public string DecryptString(string cipherString)
        {
            try
            {
                byte[] keyArray;
                byte[] toEncryptArray = Convert.FromBase64String(cipherString);

                System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

                tdes.Clear();
                return UTF8Encoding.UTF8.GetString(resultArray);
            }
            catch (Exception e)
            {
                Console.WriteLine("DecryptString exception : " + e.ToString());
                return null;
            }
        }
예제 #18
0
        public static AptimaLicenseInfo DecryptKey(string licenseKey, string securityKey, int inputStringLength)
        {
            ////Decrypt

            byte[] keyArray;
            byte[] toEncryptArray = Convert.FromBase64String(licenseKey);
 
            keyArray = UTF8Encoding.UTF8.GetBytes(securityKey);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();
            string outputString = UTF8Encoding.UTF8.GetString(resultArray);
            if (outputString.Length != inputStringLength)
            {//invalid output string! 
                return new AptimaLicenseInfo("Invalid license key! (Return string has incorrect length)");
            }

            ////populate

            return PopulateLicenseInfo(outputString);            
        }
예제 #19
0
        public string Decrypt(string message)
        {
            byte[] results;
            UTF8Encoding utf8 = new UTF8Encoding();
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] deskey = md5.ComputeHash(utf8.GetBytes(Passphrase));
            TripleDESCryptoServiceProvider desalg = new TripleDESCryptoServiceProvider();
            desalg.Key = deskey;
            desalg.Mode = CipherMode.ECB;
            desalg.Padding = PaddingMode.PKCS7;
            byte[] decryptData = Convert.FromBase64String(message);
            try
            {
                //To transform the utf binary code to md5 decrypt
                ICryptoTransform decryptor = desalg.CreateDecryptor();
                results = decryptor.TransformFinalBlock(decryptData, 0, decryptData.Length);
            }
            finally
            {
                desalg.Clear();
                md5.Clear();

            }
            //TO convert decrypted binery code to string
            return utf8.GetString(results);
        }
예제 #20
0
        public static string Decrypt(string cipherString)
        {
            try
            {
                byte[] keyArray;
                //get the byte code of the string

                byte[] toEncryptArray = Convert.FromBase64String(cipherString);

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(Key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(
                                     toEncryptArray, 0, toEncryptArray.Length);
                tdes.Clear();

                return UTF8Encoding.UTF8.GetString(resultArray);
            }
            catch (Exception ex)
            {
                return string.Empty;
            }
        }
        private const string secureKey = "QaZ1wSx2Edc3RfV4"; //Important Security Key

        #endregion Fields

        #region Methods

        public string Decrypt(string encryptedString)
        {
            try
            {

                byte[] extractBytes = Convert.FromBase64String(encryptedString);   //getting the string to decrypt

                MD5CryptoServiceProvider descObj = new MD5CryptoServiceProvider();  //creating an instance of MD5CryptoServiceProvider
                   byte[] hashCompute = descObj.ComputeHash(UTF8Encoding.UTF8.GetBytes(secureKey));

                    descObj.Clear();  //releasing resourse

                TripleDESCryptoServiceProvider DESCD = new TripleDESCryptoServiceProvider();

                DESCD.Key = hashCompute;  //secure Key is being set

                DESCD.Mode = CipherMode.ECB;     //Electronic Code Book Mode

                DESCD.Padding = PaddingMode.PKCS7;  //Padding

                ICryptoTransform ICTransform = DESCD.CreateDecryptor();
                byte[] finalResult = ICTransform.TransformFinalBlock(                          //Transforming byte array to finalResult
                                     extractBytes, 0, extractBytes.Length);

                DESCD.Clear();

                return UTF8Encoding.UTF8.GetString(finalResult);  //Return Decrypted Text
            }
            catch (Exception ex)
            {
                return ex.ToString();

            }
        }
예제 #22
0
 public static string Decrypt3DES(string CallPassword, string input, string key)
 {
     if (CallPassword != "ShoveSoft CO.,Ltd -- by Shove 20050709 深圳宝安")
     {
         return "";
     }
     TripleDESCryptoServiceProvider provider = new TripleDESCryptoServiceProvider();
     provider.Key = Encoding.UTF8.GetBytes(key);
     provider.Mode = CipherMode.ECB;
     provider.Padding = PaddingMode.Zeros;
     ICryptoTransform transform = provider.CreateDecryptor();
     byte[] inputBuffer = new byte[input.Length / 2];
     for (int i = 0; i < (input.Length / 2); i++)
     {
         inputBuffer[i] = (byte) Convert.ToInt16(input.Substring(i * 2, 2), 0x10);
     }
     string str = "";
     try
     {
         str = Encoding.UTF8.GetString(transform.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length));
     }
     catch
     {
     }
     return TrimSlashZero(str);
 }
예제 #23
0
 /// <summary>
 /// 使用给定密钥解密数据
 /// </summary>
 /// <param name="encrypted">密文</param>
 /// <param name="key">密钥</param>
 /// <returns>明文</returns>
 public static byte[] Decrypt(byte[] encrypted, byte[] key)
 {
     TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
     des.Key = MakeMD5(key);
     des.Mode = CipherMode.ECB;
     return des.CreateDecryptor().TransformFinalBlock(encrypted, 0, encrypted.Length);
 }
        public static string DecryptString(string Message)
        {
            byte[] Results;
            string passphrase = ReadCert();

            System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();
            MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
            byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(passphrase));
            TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();
            TDESAlgorithm.Key = TDESKey;
            TDESAlgorithm.Mode = CipherMode.ECB;
            TDESAlgorithm.Padding = PaddingMode.PKCS7;
            byte[] DataToDecrypt = Convert.FromBase64String(Message);
            try
            {
                ICryptoTransform Decryptor = TDESAlgorithm.CreateDecryptor();
                Results = Decryptor.TransformFinalBlock(DataToDecrypt, 0, DataToDecrypt.Length);
            }
            finally
            {
                TDESAlgorithm.Clear();
                HashProvider.Clear();
            }
            return UTF8.GetString(Results);
        }
예제 #25
0
        public static string Decrypt(string cypherString)
        {
            byte[] keyArray;
            byte[] toDecryptArray = StringToByteArray(cypherString);

            MD5CryptoServiceProvider hashmd = new MD5CryptoServiceProvider();
            keyArray = hashmd.ComputeHash(UTF8Encoding.UTF8.GetBytes(ENCRYPTION_KEY));
            hashmd.Clear();

            TripleDESCryptoServiceProvider tDes = new TripleDESCryptoServiceProvider();
            tDes.Key = keyArray;
            tDes.Mode = CipherMode.ECB;
            tDes.Padding = PaddingMode.PKCS7;
            ICryptoTransform cTransform = tDes.CreateDecryptor();
            try
            {
                byte[] resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length);

                tDes.Clear();
                return UTF8Encoding.UTF8.GetString(resultArray, 0, resultArray.Length);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #26
0
 public static ICryptoTransform CreateDecryptor(string key, CryptionType type)
 {
     ICryptoTransform transform;
     SHA512 sha512 = new SHA512CryptoServiceProvider();
     var bytes = sha512.ComputeHash(Sha1(key).ToAsciiBytes());
     switch (type)
     {
         case CryptionType.Aes:
             var aes = Rijndael.Create();
             aes.Mode = CipherMode.CBC;
             transform = aes.CreateDecryptor(bytes.Skip(17).Take(32).ToArray(), bytes.Skip(17).Take(16).ToArray());
             aes.Clear();
             break;
         case CryptionType.Des:
             var des = new DESCryptoServiceProvider { Mode = CipherMode.CBC };
             transform = des.CreateDecryptor(bytes.Skip(17).Take(8).ToArray(), bytes.Skip(17).Take(16).ToArray());
             des.Clear();
             break;
         default:
             var tripleDes = new TripleDESCryptoServiceProvider { Mode = CipherMode.CBC };
             transform = tripleDes.CreateDecryptor(bytes.Skip(17).Take(24).ToArray(), bytes.Skip(17).Take(16).ToArray());
             tripleDes.Clear();
             break;
     }
     return transform;
 }
예제 #27
0
        /// <summary>
        /// Returns a decrypted string by a key
        /// </summary>
        /// <remarks>
        /// If something is broken this method returns an empty string
        /// </remarks>
        /// <param name="text">Text to decrypt</param>
        /// <param name="key">Key to decrypt</param>
        /// <param name="encoding" >Encoding to get bytes. UTF8 by default.</ param >
        /// <returns></returns>
        public static String Decrypt(String textoEncriptado, String clave, Encoding encoding = null)
        {
            try
            {
                if (String.IsNullOrEmpty(textoEncriptado) || String.IsNullOrEmpty(clave))
                    return String.Empty;

                byte[] keyBytes;
                byte[] encryptedBytes = Convert.FromBase64String(textoEncriptado);

                //Create a MD5 object to obtain a hash
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();

                keyBytes = hashmd5.ComputeHash(encoding.GetBytes(clave));
                hashmd5.Clear();

                //Create a Triple DES object to decrypt
                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

                tdes.Key = keyBytes;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();

                byte[] resultArray = cTransform.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length);
                tdes.Clear();

                return encoding.GetString(resultArray);
            }
            catch (Exception)
            {
                return String.Empty;
            }
        }
예제 #28
0
        public static string Decrypt(string value)
        {
            byte[] toDecryptArray = Convert.FromBase64String( value );
            byte[] keyArray = Convert.FromBase64String( Config.Manager.Framework.Encryption.Key );
            byte[] ivArray = Convert.FromBase64String(Config.Manager.Framework.Encryption.IV);

            TripleDESCryptoServiceProvider tDes = new TripleDESCryptoServiceProvider();
            tDes.Key = keyArray;
            tDes.Mode = CipherMode.CBC;
            tDes.Padding = PaddingMode.PKCS7;
            tDes.IV = ivArray;

            ICryptoTransform cTransform = tDes.CreateDecryptor();
            try
            {
                byte[] resultArray = cTransform.TransformFinalBlock( toDecryptArray, 0, toDecryptArray.Length );

                tDes.Clear();
                return UTF8Encoding.UTF8.GetString( resultArray, 0, resultArray.Length );
            }
            catch( Exception ex )
            {
                throw ex;
            }
        }
예제 #29
0
        //Giai ma  HashMD5 và TripleDES
        public string Decrypt(string cipherString, bool i_blUseHashing)
        {
            byte[] v_arrKey;
            byte[] v_arrEncrypt = new byte[(int)cipherString.Length];
            try
            {
                v_arrEncrypt = Convert.FromBase64String(cipherString);
            }
            catch (Exception v_ex)
            {
                throw v_ex;
            }
            string v_strKey = "fatherofbill";
            if (i_blUseHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                v_arrKey = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(v_strKey));
                hashmd5.Clear();
            }
            else
            {
                v_arrKey = UTF8Encoding.UTF8.GetBytes(v_strKey);
            }
            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = v_arrKey;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(v_arrEncrypt, 0, v_arrEncrypt.Length);

            tdes.Clear();
            return UTF8Encoding.UTF8.GetString(resultArray);
        }
        /// <summary>
        /// Decrypts to provided string parameter.
        /// </summary>
        public static string Decrypt(string s)
        {
            if (s == null || s.Length == 0) return string.Empty;

            string result = string.Empty;

            try
            {
                byte[] buffer = Convert.FromBase64String(s);

                TripleDESCryptoServiceProvider des =
                    new TripleDESCryptoServiceProvider();

                MD5CryptoServiceProvider MD5 =
                    new MD5CryptoServiceProvider();

                des.Key =
                    MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(cryptoKey));

                des.IV = IV;

                result = Encoding.ASCII.GetString(
                    des.CreateDecryptor().TransformFinalBlock(
                    buffer, 0, buffer.Length));
            }
            catch
            {
                throw;
            }

            return result;
        }
        public static string giaiMa(string strGiaiMa)
        {
            byte[] arrKey;
            byte[] arrMahoa = Convert.FromBase64String(strGiaiMa);
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Lấy giá trị key từ file Web.config
            string keyConfig = (string)settingsReader.GetValue("keyMD5", typeof(String));

            MD5CryptoServiceProvider serviceMD5 = new MD5CryptoServiceProvider();
            arrKey = serviceMD5.ComputeHash(UTF8Encoding.UTF8.GetBytes(keyConfig));
            serviceMD5.Clear(); //Giải phóng tài nguyên
            TripleDESCryptoServiceProvider tdsp = new TripleDESCryptoServiceProvider();

            //Thiết lập 1 key cho thuật toán giải mã
            tdsp.Key = arrKey;

            //Chọn phương thức giải mã. Ở đây chúng ta chọn ECB(Electronic code Book) [1]
            tdsp.Mode = CipherMode.ECB;

            //Thêm phương thức giải mã IS010126 (random chuỗi kết quả) [2]
            tdsp.Padding = PaddingMode.ISO10126;

            ICryptoTransform cTransform = tdsp.CreateDecryptor();
            byte[] arrKQ = cTransform.TransformFinalBlock(arrMahoa, 0, arrMahoa.Length);
            tdsp.Clear(); //Giải phóng tài nguyên của TripleDES Encryptor

            // Kết quả giải mã được trả về 1 giá trị kiểu String
            return UTF8Encoding.UTF8.GetString(arrKQ);
        }
예제 #32
0
        }//end method

        /// <summary>
        /// 3des解密字符6
        /// </summary>
        /// <param name="a_strString">要解密的字符串</param>
        /// <param name="a_strKey">密钥</param>
        /// <returns>解密后的字符串</returns>
        /// <exception cref="">密钥错误</exception>
        /// <remarks>静态方法,采用默认utf8编码</remarks>
        public static string Decrypt3DES(this string a_strString, string a_strKey)
        {
            System.Security.Cryptography.TripleDESCryptoServiceProvider DES = new
                                                                              System.Security.Cryptography.TripleDESCryptoServiceProvider();
            System.Security.Cryptography.MD5CryptoServiceProvider hashMD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

            DES.Key  = hashMD5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(a_strKey));
            DES.Mode = System.Security.Cryptography.CipherMode.ECB;

            System.Security.Cryptography.ICryptoTransform DESDecrypt = DES.CreateDecryptor();

            string result = "";

            try
            {
                byte[] Buffer = Convert.FromBase64String(a_strString);
                result = System.Text.Encoding.UTF8.GetString(DESDecrypt.TransformFinalBlock
                                                                 (Buffer, 0, Buffer.Length));
            }
            catch (Exception e)
            {
#if DEBUG
                Console.WriteLine("错误:{0}", e);
#endif//DEBUG
                throw (new Exception("Invalid Key or input string is not a valid base64 string", e));
            }

            return(result);
        }//end method
 //解密
 private static string DES3Decrypt(string data, string key)
 {
     System.Security.Cryptography.TripleDESCryptoServiceProvider DES = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
     DES.Key     = System.Text.ASCIIEncoding.ASCII.GetBytes(key);
     DES.Mode    = System.Security.Cryptography.CipherMode.ECB;
     DES.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
     System.Security.Cryptography.ICryptoTransform DESDecrypt = DES.CreateDecryptor();
     byte[] Buffer = Convert.FromBase64String(data);
     return(System.Text.Encoding.UTF8.GetString(DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length)));
 }
예제 #34
0
 public static byte[] smethod_20(byte[] byte_0, string string_0)
 {
     System.Security.Cryptography.TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
     tripleDESCryptoServiceProvider.Key     = System.Text.Encoding.UTF8.GetBytes(string_0);
     tripleDESCryptoServiceProvider.Mode    = System.Security.Cryptography.CipherMode.ECB;
     tripleDESCryptoServiceProvider.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
     System.Security.Cryptography.ICryptoTransform cryptoTransform = tripleDESCryptoServiceProvider.CreateDecryptor();
     byte[] array = cryptoTransform.TransformFinalBlock(byte_0, 0, byte_0.Length);
     tripleDESCryptoServiceProvider.Clear();
     System.Array.Resize <byte>(ref array, array.Length - 1);
     return(array);
 }
    public string DecryptTripleDES(string base64Text, string Key)
    {
        System.Security.Cryptography.TripleDESCryptoServiceProvider DES = new System.Security.Cryptography.TripleDESCryptoServiceProvider();

        System.Security.Cryptography.MD5CryptoServiceProvider hashMD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();

        DES.Key = hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(Key));

        DES.Mode = System.Security.Cryptography.CipherMode.ECB;

        System.Security.Cryptography.ICryptoTransform DESDecrypt = DES.CreateDecryptor();

        Buffer = Convert.FromBase64String(base64Text);

        string DecTripleDES = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));

        return(DecTripleDES);
    }
예제 #36
0
        public static string decryptDES3(string strData, string strKey)
        {
            string strDecrypt = strData;

            byte[] arrData = hex2bytes(strData);

            System.Security.Cryptography.TripleDESCryptoServiceProvider provDES3
                             = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
            provDES3.Key     = System.Text.UTF8Encoding.UTF8.GetBytes(strKey.Substring(0, 24));
            provDES3.Mode    = System.Security.Cryptography.CipherMode.CBC;
            provDES3.IV      = hex2bytes("0000000000000000");                  // this is important !!
            provDES3.Padding = System.Security.Cryptography.PaddingMode.PKCS7; // this is OK

            System.Security.Cryptography.ICryptoTransform decryptor = provDES3.CreateDecryptor();
            byte[] arrResult = decryptor.TransformFinalBlock(arrData, 0, arrData.Length);
            provDES3.Clear();

            strDecrypt = System.Text.UTF8Encoding.UTF8.GetString(arrResult);
            return(strDecrypt);
        }
예제 #37
0
 /// <summary>
 /// Giải mã chuỗi mã hóa
 /// </summary>
 /// <param name="toDecrypt">Chuỗi cần giải mã</param>
 /// <param name="key">khóa giải mã</param>
 /// <param name="useHashing">Giải mã chuỗi mã hóa MD5 hay mã hóa UTF8 bình thường</param>
 /// <returns>Chuỗi giải mã</returns>
 public static string _mDecrypt(string toDecrypt, string key, bool useHashing)
 {
     byte[] keyArray;
     byte[] toEncryptArray = Convert.FromBase64String(toDecrypt);
     if (useHashing)
     {
         System.Security.Cryptography.MD5CryptoServiceProvider hashmd5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
         keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
     }
     else
     {
         keyArray = UTF8Encoding.UTF8.GetBytes(key);
     }
     System.Security.Cryptography.TripleDESCryptoServiceProvider tdes = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
     tdes.Key     = keyArray;
     tdes.Mode    = System.Security.Cryptography.CipherMode.ECB;
     tdes.Padding = System.Security.Cryptography.PaddingMode.PKCS7;
     System.Security.Cryptography.ICryptoTransform cTransform = tdes.CreateDecryptor();
     byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
     return(UTF8Encoding.UTF8.GetString(resultArray));
 }
예제 #38
0
        public static string Decrypt(string value)
        {
            using (TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider())
                using (MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider())
                {
                    des.Key  = hashmd5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(cypPassword));
                    des.Mode = CipherMode.ECB;
                    using (ICryptoTransform desdencrypt = des.CreateDecryptor())
                    {
                        try
                        {
                            byte[] buff = System.Convert.FromBase64String(value);
                            buff = desdencrypt.TransformFinalBlock(buff, 0, buff.Length);
                            return(ASCIIEncoding.ASCII.GetString(buff));
                        }
                        catch (FormatException) { }
                        catch (CryptographicException) { }
                    }
                }

            return(string.Empty);
        }
예제 #39
0
 private static string Decrypt(string text, System.Security.Cryptography.TripleDESCryptoServiceProvider Des)
 {
     System.Security.Cryptography.ICryptoTransform desdencrypt = Des.CreateDecryptor();
     byte[] buff = Convert.FromBase64String(text);
     return(System.Text.ASCIIEncoding.ASCII.GetString(desdencrypt.TransformFinalBlock(buff, 0, buff.Length)));
 }
예제 #40
0
        public static string TripleDESDecrypt(string pToDecrypt, string key = "")
        {
            string result;

            try
            {
                key = (string.IsNullOrWhiteSpace(key) ? EncryptHelper.strKey : key);
                byte[] array = new byte[pToDecrypt.Length / 2];
                for (int i = 0; i < pToDecrypt.Length / 2; i++)
                {
                    int num = System.Convert.ToInt32(pToDecrypt.Substring(i * 2, 2), 16);
                    array[i] = (byte)num;
                }
                TripleDESCryptoServiceProvider tripleDESCryptoServiceProvider = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
                tripleDESCryptoServiceProvider.Key  = System.Text.Encoding.ASCII.GetBytes(key);
                tripleDESCryptoServiceProvider.Mode = System.Security.Cryptography.CipherMode.ECB;
                System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
                System.Security.Cryptography.CryptoStream cryptoStream = new System.Security.Cryptography.CryptoStream(memoryStream, tripleDESCryptoServiceProvider.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
                cryptoStream.Write(array, 0, array.Length);
                cryptoStream.FlushFinalBlock();
                cryptoStream.Close();
                memoryStream.Close();
                result = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
            }
            catch (Exception ex)
            {
                result = ex.ToString();
            }
            return(result);
        }
예제 #41
0
 public static System.Security.Cryptography.ICryptoTransform GetDecServiceProvier(byte[] key, byte[] IV)
 {
     System.Security.Cryptography.TripleDESCryptoServiceProvider loc0 = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
     loc0.Mode = System.Security.Cryptography.CipherMode.CBC;
     return(loc0.CreateDecryptor(key, IV));
 }
예제 #42
0
        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string Decrypt_DES(string str)
        {
            System.Security.Cryptography.TripleDESCryptoServiceProvider des = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
            int x;

            byte[] inputByteArray = new byte[str.Length / 2];
            for (x = 0; x < str.Length / 2; x++)
            {
                inputByteArray[x] = (byte)(Convert.ToInt32(str.Substring(x * 2, 2), 16));
            }
            des.Key = Convert.FromBase64String(GetMD5Hash(key));
            des.IV  = Convert.FromBase64String("mjyxT92CmbQ=");
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
            cs.Write(inputByteArray, 0, inputByteArray.Length);
            cs.FlushFinalBlock();

            return(System.Text.Encoding.Unicode.GetString(ms.ToArray()));
        }
예제 #43
0
        /// <summary>
        /// DES多重加密解密
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static String Decrypt_DES(String str)
        {
            str = str.Trim();
            System.Security.Cryptography.TripleDESCryptoServiceProvider des = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
            Int32 x;

            Byte[] inputByteArray = new Byte[str.Length / 2];
            for (x = 0; x < str.Length / 2; x++)
            {
                inputByteArray[x] = (Byte)(Convert.ToInt32(str.Substring(x * 2, 2), 16));
            }
            des.Key = Convert.FromBase64String("uwniTq6wza2nU3/cCVxTScpjhlv1Tl5s");
            des.IV  = Convert.FromBase64String("ld6Et92CmbQ=");
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
            cs.Write(inputByteArray, 0, inputByteArray.Length);
            cs.FlushFinalBlock();
            System.Text.StringBuilder ret = new System.Text.StringBuilder();
            return(System.Text.Encoding.Unicode.GetString(ms.ToArray()));
        }