Last active
May 18, 2020 16:03
-
-
Save rhyskentish/01752b64823ff1f54557875c18c44a25 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { KeyManagementServiceClient } = require('@google-cloud/kms'); | |
| const projectId = <YourProjectID>; | |
| const locationId = <YourPreferedStorageLocationID>; //Based on the google cloud regions e.g. us-central1 | |
| const keyRingId = <KeyRingID>; | |
| const keyId = <YourKeyId>; | |
| 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: keyId, | |
| 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