Skip to content

Instantly share code, notes, and snippets.

@DonerKebab
Created August 2, 2019 04:19
Show Gist options
  • Save DonerKebab/e0192d2fa5a8c222c656e844731ef186 to your computer and use it in GitHub Desktop.
Save DonerKebab/e0192d2fa5a8c222c656e844731ef186 to your computer and use it in GitHub Desktop.
encryptData: async function() {
const kms = new AWS.KMS();
const params = {
KeyId: "arn:aws:kms:eu-west-1:846317326898:key/937948cd-8e08-49cb-9a59-5e2e62e7f70c", // your key alias or full ARN key
Plaintext: "nguyen huy phuong - 987897 - 123456", // your super secret.
}
kms.encrypt(params).promise().then(data => {
const base64EncryptedString = data.CiphertextBlob.toString('base64');
console.log('base64 encrypted string: ' + base64EncryptedString);
return base64EncryptedString;
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment