private static async Task Main(string[] args) { Console.WriteLine("Compression Utility Nuget Library"); Console.WriteLine($"Version {typeof(ICompressionUtilityAsync).Assembly.GetName().Version} - Example CLI \n"); if (args.Length != 2) { goto error; } if (args[0] == "-c") { string compressed = await compressionUtility.Compress(args[1]); Console.WriteLine("COMPRESSED STRING: " + compressed); return; } if (args[0] == "-d") { string decompressed = await compressionUtility.Decompress(args[1]); Console.WriteLine("DECOMPRESSED STRING: " + decompressed); return; } error: Console.WriteLine("INVALID ARGS. Correct usage: \nCompressing:\t-c \"String to compress here *@% 123\" \nDecompressing:\t-d \"H4sIAAAAAAAECgtxDQ4BALiT6u4EAAAA\" \n\n"); }
/// <summary> /// Asynchronous variant of <see cref="IKeyExchange.DecompressAndDecryptPrivateKey"/>. /// </summary> /// <param name="encryptedCompressedKey">The encrypted and compressed private key that you'd get from/to the backend (THE SERVER NEVER HAS YOUR PRIVATE KEY IN PLAIN TEXT).</param> /// <param name="userPassword">The user's password (NOT the hash).</param> /// <returns>The raw PEM-formatted private RSA Key (ready to be assigned to <see cref="User.PrivateKeyPem"/>).</returns> public async Task <string> DecompressAndDecryptPrivateKeyAsync(string encryptedCompressedKey, string userPassword) { string decompressedKey = await compressionUtilityAsync.Decompress(encryptedCompressedKey).ConfigureAwait(false); return(await aes.DecryptWithPasswordAsync(decompressedKey, userPassword).ConfigureAwait(false)); }