Exemple #1
0
        /// <summary>
        /// <para>Decrypts cipher text using DPAPI.</para>
        /// </summary>
        /// <param name="cipherText"><para>The cipher text for which you want to decrypt.</para></param>
        /// <returns><para>The resulting plain text.</para></returns>
        /// <seealso cref="ISymmetricCryptoProvider.Decrypt"/>
        public byte[] Decrypt(byte[] cipherText)
        {
            DpapiSymmetricCryptoProviderData data = GetDpapiSymmetricCryptoProviderDataFromCursor();

            byte[] result = DpapiCrypto.Decrypt(cipherText, data.DataProtectionMode.Entropy);
            SecurityCryptoSymmetricDecryptionEvent.Fire(string.Empty);
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Decrypts a secret using the configured <c>SymmetricAlgorithm</c>.
        /// <seealso cref="ISymmetricCryptoProvider.Decrypt"/>
        /// </summary>
        /// <param name="ciphertext"><para>The cipher text for which you want to decrypt.</para></param>
        /// <returns><para>The resulting plain text.</para></returns>
        /// <seealso cref="ISymmetricCryptoProvider.Decrypt"/>
        public byte[] Decrypt(byte[] ciphertext)
        {
            ArgumentValidation.CheckForNullReference(ciphertext, "encryptedText");
            ArgumentValidation.CheckForZeroBytes(ciphertext, "encryptedText");

            byte[] output = null;

            SymmetricAlgorithmProviderData data = GetSymmetricAlgorithmProviderDataFromCursor();

            SymmetricCryptographer crypto = new SymmetricCryptographer(data.AlgorithmType, data.Key);

            output = crypto.Decrypt(ciphertext);
            SecurityCryptoSymmetricDecryptionEvent.Fire(string.Empty);
            return(output);
        }
 private void FireSecuritySymmetricDecryptionEvent()
 {
     SecurityCryptoSymmetricDecryptionEvent.Fire(testMessage);
 }
 private void FireSecurityCryptoSymmetricDecryptionEvent()
 {
     SecurityCryptoSymmetricDecryptionEvent.Fire("test");
 }