/// <summary> /// Encrypts the specified plaintext object to a Base64 string. /// </summary> /// <typeparam name="T"> /// The type of the object that is encrypted. /// </typeparam> /// <param name="target"> /// The current <see cref="ISymmetricProcessor{T}" />. /// </param> /// <param name="plaintextObject"> /// The plaintext object to encrypt. /// </param> /// <param name="key"> /// The key derivation bits and algorithm specification used to transform the object. /// </param> /// <returns> /// The resulting ciphertext as a Base64 string. /// </returns> /// <exception cref="SecurityException"> /// An exception was raised during encryption or serialization. /// </exception> public static String EncryptToBase64String <T>(this ISymmetricProcessor <T> target, T plaintextObject, SecureSymmetricKey key) => Convert.ToBase64String(target.Encrypt(plaintextObject, key));
/// <summary> /// Encrypts the specified plaintext object to a Base64 string. /// </summary> /// <typeparam name="T"> /// The type of the object that is encrypted. /// </typeparam> /// <param name="target"> /// The current <see cref="ISymmetricProcessor{T}" />. /// </param> /// <param name="plaintextObject"> /// The plaintext object to encrypt. /// </param> /// <param name="key"> /// The key derivation bits used to transform the object. /// </param> /// <param name="algorithm"> /// The algorithm specification used to transform the object. /// </param> /// <returns> /// The resulting ciphertext as a Base64 string. /// </returns> /// <exception cref="SecurityException"> /// An exception was raised during encryption or serialization. /// </exception> public static String EncryptToBase64String <T>(this ISymmetricProcessor <T> target, T plaintextObject, SecureBuffer key, SymmetricAlgorithmSpecification algorithm) => Convert.ToBase64String(target.Encrypt(plaintextObject, key, algorithm));