Created
May 18, 2020 15:52
-
-
Save rhyskentish/2061ba1e3f38c879ac8ea64c54d949bd to your computer and use it in GitHub Desktop.
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 projectId = <YourProjectID>; | |
const locationId = <YourPreferedStorageLocationID>; //Based on the google cloud regions e.g. us-central1 | |
const keyRingId = <KeyRingID>; | |
const kmsClient = new KeyManagementServiceClient(); | |
const locationName = kmsClient.locationPath(projectId, locationId); | |
async function createKeySymmetricEncryptDecrypt() { | |
const keyRingName = await kmsClient.keyRingPath(projectId, locationId, keyRingId); | |
const [key] = await kmsClient.createCryptoKey({ | |
parent: keyRingName, | |
cryptoKeyId: <YourKeyId>, | |
cryptoKey: { | |
purpose: 'ENCRYPT_DECRYPT', | |
versionTemplate: { | |
algorithm: 'GOOGLE_SYMMETRIC_ENCRYPTION', | |
}, | |
}, | |
}); | |
console.log(`Created symmetric key: ${key.name}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment