All Cloud KMS code samples
This page contains code samples for Cloud Key Management Service. To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.
Check an import job
Check the state of an import job in Cloud KMS.
- Cloud Key Management Service
- Google Cloud
- Go
- Python
- JavaScript
- Node JS
- Java
Get the IAM policy for a resource
Get the IAM policy for a resource.
- Cloud Key Management Service
- Google Cloud
- JavaScript
- Python
- C#
- Java
- PHP
- Node JS
- Go
- Ruby
Verify an asymmetric signature of an EC key
Verify the signature of a message signed with an asymmetric EC key.
- Google Cloud
- Cloud Key Management Service
- Ruby
- PHP
- JavaScript
- Go
- C#
- Java
- Node JS
- Python
Configure automatic key rotation
Configure an automatic key rotation schedule.
- Google Cloud
- Cloud Key Management Service
- Python
- Node JS
- C#
- JavaScript
- PHP
- Ruby
- Go
- Java
Update the primary version of a key
Update the primary version of a key.
- Google Cloud
- Cloud Key Management Service
- C#
- PHP
- Go
- Node JS
- Java
- Python
- Ruby
- JavaScript
Verify a certificate chain
Get a manufacturer certificate chain and verify the attestation.
- Cloud Key Management Service
- Google Cloud
- Python
Create a MAC signature
Sign a message using the public key part of an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- PHP
- Go
- Python
- Java
- Node JS
- Ruby
- C#
- JavaScript
Remove labels from an existing key
Remove labels from an existing key.
- Google Cloud
- Cloud Key Management Service
- C#
- Go
- Java
- Python
- PHP
- Node JS
- JavaScript
- Ruby
Create a symmetric key
Create a new symmetric encryption/decryption key in Cloud KMS.
- Google Cloud
- Cloud Key Management Service
- Go
- Python
- Java
- PHP
- C#
- Node JS
- Ruby
- JavaScript
Decrypt with a symmetric key
Decrypt the ciphertext by using the symmetric key.
- Google Cloud
- Cloud Key Management Service
- Node JS
- Python
- PHP
- JavaScript
- Java
- C#
- Ruby
- Go
Add a rotation schedule to an existing key
Add a rotation schedule to an existing key.
- Google Cloud
- Cloud Key Management Service
- Ruby
- C#
- PHP
- Python
- JavaScript
- Java
- Go
- Node JS
Import a manually wrapped key
Import a key into Cloud KMS that you have wrapped manually.
- Google Cloud
- Cloud Key Management Service
- Python
- Node JS
- JavaScript
- Go
- Java
Decrypt with an asymmetric key
Decrypt the ciphertext by using an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- Java
- Python
- PHP
- JavaScript
- Go
- Ruby
- C#
- Node JS
Get a key and its labels
Get a key and its labels.
- Cloud Key Management Service
- Google Cloud
- C#
- Java
- Ruby
- JavaScript
- Python
- PHP
- Node JS
- Go
Create a key ring
Create a key ring.
- Google Cloud
- Cloud Key Management Service
- Node JS
- PHP
- Go
- JavaScript
- Java
- Python
- Ruby
- C#
Get the public key for an asymmetric key
Get the public key for an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- Python
- Java
- PHP
- Node JS
- Ruby
- Go
- C#
- JavaScript
Restore a key version scheduled for destruction
Restore a key version that is scheduled for destruction.
- Cloud Key Management Service
- Google Cloud
- Node JS
- Java
- Go
- Python
- Ruby
- PHP
- C#
- JavaScript
Enable a key version
Enable a key version.
- Cloud Key Management Service
- Google Cloud
- PHP
- C#
- JavaScript
- Python
- Node JS
- Go
- Ruby
- Java
Create a new key version
Create a new version of the given key.
- Google Cloud
- Cloud Key Management Service
- Ruby
- PHP
- Java
- JavaScript
- Python
- C#
- Go
- Node JS
Destroy a key version
Schedule the destruction of the given key version.
- Cloud Key Management Service
- Google Cloud
- Java
- Node JS
- C#
- Go
- PHP
- JavaScript
- Python
- Ruby
Remove a rotation schedule from an existing key
Remove a rotation schedule from an existing key.
- Cloud Key Management Service
- Google Cloud
- Python
- Node JS
- Java
- C#
- Go
- Ruby
- JavaScript
- PHP
Disable a key version
Disable a key version.
- Cloud Key Management Service
- Google Cloud
- Ruby
- Java
- C#
- Node JS
- Go
- PHP
- JavaScript
- Python
Verify asymmetric signature of an RSA key
Verify the signature of a message signed with an asymmetric RSA key.
- Cloud Key Management Service
- Google Cloud
- Go
- PHP
- Java
- Node JS
- JavaScript
- Ruby
- Python
- C#
Add an IAM member to a resource
Add an IAM member to a resource.
- Google Cloud
- Cloud Key Management Service
- C#
- Python
- PHP
- Node JS
- Java
- JavaScript
- Go
- Ruby
Retrieve an asymmetric signature
Get an asymmetric signature of the SHA-256 hash of an input message using the KMS API.
- Google Cloud
- Cloud Key Management Service
- Java
- Go
- C#
- Node JS
- Python
- JavaScript
- Ruby
- PHP
Encrypt with a symmetric key
Encrypt plaintext by using a symmetric key.
- Cloud Key Management Service
- Google Cloud
- Ruby
- Node JS
- C#
- Python
- Go
- Java
- PHP
- JavaScript
Create a Cloud KMS HMAC key
Create a new key in Cloud KMS for HMAC operations.
- Google Cloud
- Cloud Key Management Service
- Ruby
- PHP
- JavaScript
- Go
- C#
- Java
- Node JS
- Python
Encrypt with an asymmetric key
Encrypt plaintext using the public key portion of an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- Node JS
- PHP
- Ruby
- C#
- JavaScript
- Go
- Java
- Python
List key rings
List key rings.
- Google Cloud
- Cloud Key Management Service
- PHP
- JavaScript
- Python
- Ruby
- Java
- Node JS
- C#
- Go
Create an asymmetric signing key
Create an asymmetric signing key.
- Cloud Key Management Service
- Google Cloud
- Java
- PHP
- Ruby
- Node JS
- Python
- C#
- Go
- JavaScript
Get random bytes from an HSM
Retrieve random bytes from the random number generator in Cloud HSM.
- Google Cloud
- Cloud Key Management Service
- Java
- JavaScript
- Python
- PHP
- Node JS
- Go
- C#
- Ruby
Remove an IAM member from a resource
Remove an IAM member from a resource.
- Cloud Key Management Service
- Google Cloud
- Go
- Ruby
- Node JS
- Python
- C#
- PHP
- JavaScript
- Java
Create an HSM key
Create a Cloud HSM key on the specified key ring and location.
- Google Cloud
- Cloud Key Management Service
- Ruby
- Go
- C#
- Node JS
- JavaScript
- Python
- PHP
- Java
Create an import job
Create a new import job in Cloud KMS.
- Cloud Key Management Service
- Google Cloud
- Python
- Java
- Go
- JavaScript
- Node JS
Verify a MAC signature
Verify the signature of data from an HMAC key.
- Cloud Key Management Service
- Google Cloud
- Python
- JavaScript
- Node JS
- Java
- Go
- C#
- Ruby
- PHP
Check import job
Check the state of an import job in Cloud KMS.
- Google Cloud
- Cloud Key Management Service
- Node JS
- JavaScript
- Python
- Java
- Go
Get a key version's attestation
Get an HSM-backend key's attestation.
- Google Cloud
- Cloud Key Management Service
- Node JS
- Ruby
- Go
- JavaScript
- Python
- PHP
- Java
- C#
Create a key with labels
When creating a key, you can add labels by providing one or more key-value pairs as labels when you create your key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- PHP
- Python
- C#
- Go
- Node JS
- Ruby
- Java
Create a key for import
Set up an empty key for importing your own crypto key.
- Cloud Key Management Service
- Google Cloud
- Go
- Java
- Node JS
- JavaScript
- Python
Update labels on an existing key
Update labels on an existing key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- PHP
- Python
- C#
- Go
- Java
- Node JS
- Ruby
Create an asymmetric decryption key
Create an asymmetric decryption key.
- Google Cloud
- Cloud Key Management Service
- Python
- Go
- Ruby
- JavaScript
- PHP
- Node JS
- C#
- Java