Пример #1
0
 public static string EncryptString(string ConnString)
 {
     if (string.IsNullOrWhiteSpace(ConnString))
     {
         return(ConnString);
     }
     return(Convert.ToBase64String(EncryptAndDecrypte.EncryptString(ConnString, Convert.FromBase64String(EncryptAndDecrypte.strKey), Convert.FromBase64String(EncryptAndDecrypte.strIV))));
 }
Пример #2
0
 public static string DecrypteString(string EncryptedConnectionString)
 {
     if (string.IsNullOrWhiteSpace(EncryptedConnectionString))
     {
         return(EncryptedConnectionString);
     }
     return(EncryptAndDecrypte.DecrypteString(Convert.FromBase64String(EncryptedConnectionString), Convert.FromBase64String(EncryptAndDecrypte.strKey), Convert.FromBase64String(EncryptAndDecrypte.strIV)).TrimEnd(new char[1]));
 }
Пример #3
0
        public static void TryGetKeyAndIV(out byte[] Key, out byte[] IV)
        {
            TripleDESCryptoServiceProvider cryptoServiceProvider = new TripleDESCryptoServiceProvider();

            for (int Len = 200; Len > 0; --Len)
            {
                try
                {
                    Key = EncryptAndDecrypte.GetBytes(Len);
                    IV  = EncryptAndDecrypte.GetBytes(Len);
                    cryptoServiceProvider.CreateDecryptor(Key, IV);
                    return;
                }
                catch
                {
                }
            }
            Key = (byte[])null;
            IV  = (byte[])null;
        }