Skip to content

Instantly share code, notes, and snippets.

@TimothyJones
Created August 30, 2019 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimothyJones/2f0cbf14be0997e94f2260a955686beb to your computer and use it in GitHub Desktop.
Save TimothyJones/2f0cbf14be0997e94f2260a955686beb to your computer and use it in GitHub Desktop.
Example showing a simple promisified decryption of a KMS encrypted string
const decrypt = data =>
new Promise((resolve, reject) =>
kms.decrypt(
{
CiphertextBlob: Buffer.from(data, 'base64')
},
(err, data) => {
if (err) {
reject(err);
} else {
resolve(data.Plaintext.toString());
}
}
)
);
decrypt(process.env.SOME_PARAMETER).then(param => {
console.log(param);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment