Skip to content

Instantly share code, notes, and snippets.

@o-can
Created May 6, 2016 13:11
Show Gist options
  • Save o-can/5fd7987de78a4f171eb8fd0dcb33ef4d to your computer and use it in GitHub Desktop.
Save o-can/5fd7987de78a4f171eb8fd0dcb33ef4d to your computer and use it in GitHub Desktop.
AWSKMSClient awskmsClient = new AWSKMSClient();
awskmsClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
String token = "Dummy";
ByteBuffer plainText = ByteBuffer.wrap(token.getBytes());
EncryptRequest encryptRequest = new EncryptRequest().withKeyId(keyId).withPlaintext(plainText);
EncryptResult encryptResult = awskmsClient.encrypt(encryptRequest);
String kmsEncryptedToken = Base64.getEncoder().encodeToString(encryptResult.getCiphertextBlob().array());
System.out.println(kmsEncryptedToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment