Created
August 30, 2019 04:47
-
-
Save TimothyJones/2f0cbf14be0997e94f2260a955686beb to your computer and use it in GitHub Desktop.
Example showing a simple promisified decryption of a KMS encrypted string
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
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