Ejemplo n.º 1
0
        /// <summary>
        /// Decrypts the base64key using an internal private key.
        /// </summary>
        /// <param name="base64Text">The encrypted string in base64 format.</param>
        /// <returns>The plaintext string.</returns>
        public virtual string Decrypt(string base64Text)
        {
            if (!this._encryptionOptions.Encrypt)
            {
                return(base64Text);
            }

            string plaintext = CryptographyUtils.Decrypt(this._algorithm, base64Text, this._encryptionOptions.InternalKey);

            return(plaintext);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Encrypts the plaintext using an internal private key.
        /// </summary>
        /// <param name="plaintext">The text to encrypt.</param>
        /// <returns>An encrypted string in base64 format.</returns>
        public string Encrypt(string plaintext)
        {
            if (!this._encryptionOptions.Encrypt)
            {
                return(plaintext);
            }

            string base64Text = CryptographyUtils.Encrypt(this._algorithm, plaintext);

            return(base64Text);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Default options
 /// </summary>
 public CryptoSym()
 {
     this._encryptionOptions = new CryptoConfig();
     this._algorithm         = CryptographyUtils.CreateSymmAlgoTripleDes();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Default options
 /// </summary>
 public CryptoHash()
 {
     this._encryptionOptions = new CryptoConfig();
     this._algorithm         = CryptographyUtils.CreateHashAlgoMd5();
 }