Skip to content

Instantly share code, notes, and snippets.

@thebeebs
Created March 4, 2020 21:29
Show Gist options
  • Save thebeebs/762dfbbb1f5dde06d5ad892432c180bb to your computer and use it in GitHub Desktop.
Save thebeebs/762dfbbb1f5dde06d5ad892432c180bb to your computer and use it in GitHub Desktop.
A solution to the questiond 60207104 on stack overflow.
static void Main(string[] args)
{
var prog = new Program();
prog.MainAsync().Wait();
}
private async Task MainAsync()
{
var kmsClient = new AmazonKeyManagementServiceClient(RegionEndpoint.EUCentral1);
var dataKeyRequest = new GenerateDataKeyPairRequest
{
KeyId = KeyId,
KeyPairSpec = DataKeyPairSpec.RSA_2048
};
var dataKeyPairResponse = await kmsClient.GenerateDataKeyPairAsync(dataKeyRequest);
var privateKeyBytes = dataKeyPairResponse.PrivateKeyPlaintext.ToArray();
var privateKey = Convert.ToBase64String(privateKeyBytes);
var publicKeyBytes = dataKeyPairResponse.PublicKey.ToArray();
var publicKey = Convert.ToBase64String(publicKeyBytes);
Console.Write(privateKey);
Console.Write(publicKey);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment