Пример #1
0
        private static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: AESEncryptionUtility infile outFile");
                return(1);
            }
            string text  = args[0];
            string text2 = args[1];

            AESEncryptionUtility.Encrypt(text, text2, "test");
            AESEncryptionUtility.Decrypt(text2, "_decrypted" + text, "test");
            return(0);
        }
Пример #2
0
        public static byte[] Decrypt(byte[] cipherData, string Password)
        {
            PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(Password, new byte[]
            {
                73,
                118,
                97,
                110,
                32,
                77,
                101,
                100,
                118,
                101,
                100,
                101,
                118
            });

            return(AESEncryptionUtility.Decrypt(cipherData, passwordDeriveBytes.GetBytes(32), passwordDeriveBytes.GetBytes(16)));
        }
Пример #3
0
        public static string Decrypt(string cipherText, string Password)
        {
            byte[] cipherData = Convert.FromBase64String(cipherText);
            PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(Password, new byte[]
            {
                73,
                118,
                97,
                110,
                32,
                77,
                101,
                100,
                118,
                101,
                100,
                101,
                118
            });

            byte[] bytes = AESEncryptionUtility.Decrypt(cipherData, passwordDeriveBytes.GetBytes(32), passwordDeriveBytes.GetBytes(16));
            return(Encoding.Unicode.GetString(bytes));
        }
Пример #4
0
        private static string getExpiryfromlog()
        {
            DBConn    dBConn    = null;
            DbCommand dbCommand = null;

            try
            {
                dBConn = DBConnPool.getLogConnection();
                if (dBConn != null && dBConn.con != null)
                {
                    string result;
                    if (DBUtil.DetermineTableExist(dBConn.con, "sys_info"))
                    {
                        dbCommand             = dBConn.con.CreateCommand();
                        dbCommand.CommandText = "select * from sys_info ";
                        object obj = dbCommand.ExecuteScalar();
                        if (obj != null && obj != DBNull.Value)
                        {
                            string text = Convert.ToString(obj);
                            if (text.Length == 0)
                            {
                                result = "VALUENULL";
                                return(result);
                            }
                            try
                            {
                                text   = AESEncryptionUtility.Decrypt(text, "evaluate_date-time");
                                result = text;
                                return(result);
                            }
                            catch
                            {
                                result = "FATAL";
                                return(result);
                            }
                        }
                        result = "NOVALUE";
                        return(result);
                    }
                    result = "NOTABLE";
                    return(result);
                }
            }
            catch (Exception)
            {
                string result = "";
                return(result);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                if (dBConn != null)
                {
                    try
                    {
                        dBConn.close();
                    }
                    catch
                    {
                    }
                }
            }
            return("");
        }