Exemplo n.º 1
0
        public static string DecryptThenDecompress(this string inputString, string password)
        {
            using (MemoryStream decompressedStream = new MemoryStream())
            {
                using (MemoryStream compressedStream = new MemoryStream(AESGCM.SimpleDecryptWithPassword(Convert.FromBase64String(inputString), password)))
                {
                    using (DeflateStream decompressorStream = new DeflateStream(compressedStream, CompressionMode.Decompress))
                    {
                        decompressorStream.CopyTo(decompressedStream);
                    }

                    return(Encoding.UTF8.GetString(decompressedStream.ToArray()));
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Decrypts a simply encrypted string with a password: <seealso cref="Encrypt(string, string)"/>
 /// </summary>
 /// <param name="encryptedString">The string to decrypt.</param>
 /// <param name="password">The password to decrypt with (must be the same that was used for encrypting)</param>
 /// <returns>The decrypted string</returns>
 /// <remarks>
 /// Please understand the security limitations of symmetrical encryption with a known clear-text password.
 /// </remarks>
 public static string Decrypt(this string encryptedString, string password) => AESGCM.SimpleDecryptWithPassword(encryptedString, password);