Beispiel #1
0
        internal static string AESDecryption(string cipher, string key, string salt, Pkcs7Padding padding)
        {
            BCEngine bcEngine = new BCEngine(new AesEngine(), Encoding.UTF8);

            bcEngine.SetPadding(padding);
            return(bcEngine.Decrypt(cipher, key));
        }
        /// <summary>
        /// Decrypt cipher string and remove salt and pepper
        /// </summary>
        /// <param name="engine">Cipher engine</param>
        /// <param name="cipher">Cipher text</param>
        /// <returns>Decrypted string</returns>
        private string GetDecryptedString(BCEngine engine, string cipher)
        {
            string saltedString = engine.Decrypt(cipher, Key256Bits);

            return(saltedString.Replace(Salt, string.Empty).Replace(Pepper, string.Empty));
        }