Created
March 3, 2022 19:25
-
-
Save awswithdotnet/3a73ad15ba9e6821e0ddb19c0a1a0867 to your computer and use it in GitHub Desktop.
kms Client Program Main
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const string RequestUri = "http://localhost:5000/Message"; | |
static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Enter message:"); | |
var message = Console.ReadLine(); | |
Console.WriteLine("Original:" + message); | |
IEncrypter encrypter = new AESEncrypter(); | |
IEncryptionPackage encryptionPackage = await encrypter.Encrypt(message); | |
string jsonString = JsonSerializer.Serialize(encryptionPackage); | |
using (HttpClient httpClient = new HttpClient()) | |
{ | |
var httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); | |
httpClient.DefaultRequestHeaders.Accept.Clear(); | |
httpClient.DefaultRequestHeaders.Accept.Add( | |
new MediaTypeWithQualityHeaderValue("text/plain") | |
); | |
HttpResponseMessage response = await httpClient.PostAsync(_requestUri, httpContent); | |
string decryptedString = await response.Content.ReadAsStringAsync(); | |
Console.Write("Decrypted: " + decryptedString); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment