Example #1
0
        /// <summary>
        /// <para>Encrypts a secret using DPAPI.</para>
        /// </summary>
        /// <param name="plaintext"><para>The input for which you want to encrypt.</para></param>
        /// <returns><para>The resulting cipher text.</para></returns>
        /// <seealso cref="ISymmetricCryptoProvider.Encrypt"/>
        public byte[] Encrypt(byte[] plaintext)
        {
            DpapiSymmetricCryptoProviderData data = GetDpapiSymmetricCryptoProviderDataFromCursor();

            byte[] result = DpapiCrypto.Encrypt(plaintext, data.DataProtectionMode.Entropy);
            SecurityCryptoSymmetricEncryptionEvent.Fire(string.Empty);
            return(result);
        }
Example #2
0
        /// <summary>
        /// <para>Encrypts a secret using the configured <c>SymmetricAlgorithm</c>.</para>
        /// </summary>
        /// <param name="plaintext"><para>The input for which you want to encrypt.</para></param>
        /// <returns><para>The resulting cipher text.</para></returns>
        /// <seealso cref="ISymmetricCryptoProvider.Encrypt"/>
        public byte[] Encrypt(byte[] plaintext)
        {
            ArgumentValidation.CheckForNullReference(plaintext, "plaintext");
            ArgumentValidation.CheckForZeroBytes(plaintext, "plaintext");

            byte[] output = null;

            SymmetricAlgorithmProviderData data = GetSymmetricAlgorithmProviderDataFromCursor();

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

            output = crypto.Encrypt(plaintext);
            SecurityCryptoSymmetricEncryptionEvent.Fire(string.Empty);
            return(output);
        }
Example #3
0
 private void FireSecuritySymmetricEncryptionEvent()
 {
     SecurityCryptoSymmetricEncryptionEvent.Fire(testMessage);
 }
 private void FireSecurityCryptoSymmetricEncryptionEvent()
 {
     SecurityCryptoSymmetricEncryptionEvent.Fire("test");
 }