Example #1
0
        public void SetKeyAndVector(KeyAndVectorModel keyAndVector)
        {
            using (OracleConnection db = new OracleConnection(connectionString))
            {
                string sql = "INSERT INTO AesInfo(key, iv, identify) " +
                             "VALUES(:KEY ,:IV , 'true')";


                db.Open();

                db.Execute(sql, new { keyAndVector.key, keyAndVector.iv });
            }
        }
Example #2
0
        public KeyAndVectorModel GetKeyAndVector()
        {
            using (OracleConnection db = new OracleConnection(connectionString))
            {
                string sql1 = "SELECT nvl(identify,0) " +
                              "FROM AesInfo WHERE identify = 'true' ";

                db.Open();
                string havingValues = db.Query <string>(sql1).FirstOrDefault();

                if (havingValues == null)
                {
                    KeyAndVectorModel res = new KeyAndVectorModel();
                    return(res);
                }

                string sql2 = "SELECT key, iv " +
                              "FROM AesInfo WHERE identify = 'true' ";

                return(db.Query <KeyAndVectorModel>(sql2).FirstOrDefault());
            }
        }