/// <summary> /// Decrypts a given input stream and writes the decrypted data to the provided output stream. A buffer stream /// gets used in front of the output stream. This method expects, that both streams are read-to-use e.g. the /// input stream is at the desired position and the output stream is writable, etc. This method disposes the /// internal crypto streams. Thus, the input and output streams might get disposed as well. Please note, that /// this method writes binary data without e.g. base64 encoding. /// /// When the task finished, the entire decryption of the input stream is done. /// </summary> /// <param name="inputStream">The desired input stream. The decryption starts at the current position.</param> /// <param name="outputStream">The desired output stream. The decrypted data gets written to the current position.</param> /// <param name="password">The encryption password.</param> /// <param name="iterations">The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.</param> public static async Task Decrypt(this Stream inputStream, Stream outputStream, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020) { await CryptoProcessor.Decrypt(inputStream, outputStream, password, iterations); }
/// <summary> /// Decrypts an base64 encoded and encrypted string. Due to the necessary millions of SHA512 iterations, /// the methods runs at least several seconds in the year 2020 (approx. 5-7s). /// This method suits for small data such as telegrams, JSON data, text notes, passwords, etc. For larger /// data, might use the stream overload. Rule of thumb: If the data could be stored three times in /// the present memory, this method could be used. /// </summary> /// <param name="data">The base64 encoded and AES encrypted string. This string must be ASCII encoded.</param> /// <param name="password">The password. Must consists of 6 chars or more.</param> /// <param name="iterations">The number of iterations to derive the key. Should not be adjusted. The default is secure for the current time.</param> /// <returns>The decrypted UTF8 encoded string.</returns> public static async Task <string> Decrypt(this string data, string password, int iterations = CryptoProcessor.ITERATIONS_YEAR_2020) { return(await CryptoProcessor.Decrypt(data, password, iterations)); }