Beispiel #1
0
 public static SqlString decryptAES(SqlString message, SqlString key, SqlString iv)
 {
     byte[] mBytes   = Convert.FromBase64String(message.ToString());
     byte[] keyBytes = Convert.FromBase64String(key.ToString());
     byte[] ivBytes  = Convert.FromBase64String(iv.ToString());
     try
     {
         byte[] dText = BCAES.DecryptAES(mBytes, keyBytes, ivBytes);
         return(Encoding.UTF8.GetString(dText));
     }
     catch (Exception ex) { return(ex.Message); }
 }
Beispiel #2
0
        public static SqlString encryptAES(SqlString message, SqlString key, SqlString iv)
        {
            //byte[] key = Convert.FromBase64String(txtDKA.Text);

            //byte[] iv = new byte[16]; //derivedKeyA.Take(16).ToArray();

            byte[] mBytes   = Encoding.UTF8.GetBytes(message.ToString());
            byte[] keyBytes = Convert.FromBase64String(key.ToString());
            byte[] ivBytes  = Convert.FromBase64String(iv.ToString());
            try
            {
                return(Convert.ToBase64String(BCAES.EncryptAES(mBytes, keyBytes, ivBytes)));
            }
            catch (Exception ex) { return(ex.Message); }
        }