Beispiel #1
0
        public static string GetEncryptionKey()
        {
            WEBeSettings settings = new WEBeSettings();

            OracleDataAccess.OracleCommandData data = new OracleDataAccess.OracleCommandData();
            try
            {
                data._CommandType = CommandType.Text;
                data.CommandText  = "select encryptionkey from WEBESETTINGS";
                data.OpenWithOutTrans();

                //Executing Query
                DataSet ds = data.Execute(OracleDataAccess.ExecutionType.ExecuteDataSet) as DataSet;

                if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    settings.dt      = ds.Tables[0];
                    settings.isValid = true;
                }
            }
            catch (Exception ex)
            {
                settings.Error = ex.Message.ToString();
                //throw;
            }
            finally
            {
                data.Close();
            }

            return(settings.dt.Rows[0]["encryptionkey"].ToString());
        }
Beispiel #2
0
        public static string GetDecryptedStringWithID(string ID, string Type)
        {
            WEBeSettings settings = new WEBeSettings();

            OracleDataAccess.OracleCommandData data = new OracleDataAccess.OracleCommandData();
            string DecryptedString = string.Empty;

            try
            {
                data._CommandType = CommandType.Text;

                if (Type.ToLower() == "master")
                {
                    data.CommandText = "select note, hash from events where event_id =" + ID;
                }
                else if (Type.ToLower() == "detail")
                {
                    data.CommandText = "select note, hash from EVENTS_DATA where note_id =" + ID;
                }

                data.OpenWithOutTrans();

                //Executing Query
                DataSet ds = data.Execute(OracleDataAccess.ExecutionType.ExecuteDataSet) as DataSet;

                if ((ds != null) && (ds.Tables.Count > 0) && (ds.Tables[0].Rows.Count > 0))
                {
                    string EncryptedString = ds.Tables[0].Rows[0]["note"].ToString();
                    string Hash            = ds.Tables[0].Rows[0]["hash"].ToString();
                    DecryptedString = DecryptAESCalculateHash(EncryptedString, Hash);
                }

                if (string.IsNullOrWhiteSpace((DecryptedString)))
                {
                    DecryptedString = "Error: Message integrity has been lost.";
                }
            }
            catch (Exception ex)
            {
                settings.Error = ex.Message.ToString();
                //throw;
            }
            finally
            {
                data.Close();
            }

            return(DecryptedString);
        }