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
- Java
- Node JS
- JavaScript
- Go
- Python
Get the IAM policy for a resource
Get the IAM policy for a resource.
- Google Cloud
- Cloud Key Management Service
- Java
- Node JS
- Python
- JavaScript
- PHP
- Go
- C#
- Ruby
Verify an asymmetric signature of an EC key
Verify the signature of a message signed with an asymmetric EC key.
- Cloud Key Management Service
- Google Cloud
- C#
- Java
- Python
- Ruby
- JavaScript
- PHP
- Node JS
- Go
Configure automatic key rotation
Configure an automatic key rotation schedule.
- Google Cloud
- Cloud Key Management Service
- Node JS
- Go
- C#
- Ruby
- Python
- Java
- PHP
- JavaScript
Update the primary version of a key
Update the primary version of a key.
- Cloud Key Management Service
- Google Cloud
- Python
- PHP
- Java
- Node JS
- JavaScript
- Ruby
- C#
- Go
Verify a certificate chain
Get a manufacturer certificate chain and verify the attestation.
- Google Cloud
- Cloud Key Management Service
- Python
Create a MAC signature
Sign a message using the public key part of an asymmetric key.
- Google Cloud
- Cloud Key Management Service
- Ruby
- Go
- Java
- Node JS
- PHP
- Python
- C#
- JavaScript
Remove labels from an existing key
Remove labels from an existing key.
- Cloud Key Management Service
- Google Cloud
- Ruby
- Node JS
- Go
- PHP
- Java
- C#
- JavaScript
- Python
Create a symmetric key
Create a new symmetric encryption/decryption key in Cloud KMS.
- Cloud Key Management Service
- Google Cloud
- JavaScript
- Python
- Ruby
- PHP
- Go
- Node JS
- C#
- Java
Decrypt with a symmetric key
Decrypt the ciphertext by using the symmetric key.
- Google Cloud
- Cloud Key Management Service
- Java
- Go
- C#
- Ruby
- Python
- PHP
- Node JS
- JavaScript
Add a rotation schedule to an existing key
Add a rotation schedule to an existing key.
- Cloud Key Management Service
- Google Cloud
- PHP
- Python
- C#
- Node JS
- Java
- Go
- JavaScript
- Ruby
Import a manually wrapped key
Import a key into Cloud KMS that you have wrapped manually.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- Python
- Go
- Node JS
- Java
Decrypt with an asymmetric key
Decrypt the ciphertext by using an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- Node JS
- Go
- Ruby
- JavaScript
- C#
- PHP
- Python
- Java
Get a key and its labels
Get a key and its labels.
- Cloud Key Management Service
- Google Cloud
- Java
- Node JS
- PHP
- Ruby
- C#
- JavaScript
- Go
- Python
Create a key ring
Create a key ring.
- Google Cloud
- Cloud Key Management Service
- Java
- Python
- C#
- PHP
- Node JS
- JavaScript
- Go
- Ruby
Get the public key for an asymmetric key
Get the public key for an asymmetric key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- Java
- Node JS
- Go
- PHP
- Ruby
- Python
- C#
Restore a key version scheduled for destruction
Restore a key version that is scheduled for destruction.
- Cloud Key Management Service
- Google Cloud
- Java
- PHP
- Ruby
- JavaScript
- Python
- Go
- Node JS
- C#
Enable a key version
Enable a key version.
- Cloud Key Management Service
- Google Cloud
- Go
- Python
- Ruby
- Java
- Node JS
- C#
- JavaScript
- PHP
Create a new key version
Create a new version of the given key.
- Google Cloud
- Cloud Key Management Service
- Java
- Go
- JavaScript
- Node JS
- C#
- Ruby
- PHP
- Python
Destroy a key version
Schedule the destruction of the given key version.
- Google Cloud
- Cloud Key Management Service
- PHP
- Go
- C#
- Node JS
- Ruby
- Python
- JavaScript
- Java
Remove a rotation schedule from an existing key
Remove a rotation schedule from an existing key.
- Cloud Key Management Service
- Google Cloud
- Python
- C#
- Ruby
- Java
- JavaScript
- Node JS
- PHP
- Go
Disable a key version
Disable a key version.
- Google Cloud
- Cloud Key Management Service
- Ruby
- Python
- C#
- Node JS
- Java
- PHP
- Go
- JavaScript
Verify asymmetric signature of an RSA key
Verify the signature of a message signed with an asymmetric RSA key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- Java
- PHP
- Ruby
- Python
- C#
- Go
- Node JS
Add an IAM member to a resource
Add an IAM member to a resource.
- Google Cloud
- Cloud Key Management Service
- Python
- C#
- Ruby
- Java
- JavaScript
- Go
- PHP
- Node JS
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
- Ruby
- PHP
- JavaScript
- Python
- Node JS
- Go
- C#
- Java
Encrypt with a symmetric key
Encrypt plaintext by using a symmetric key.
- Cloud Key Management Service
- Google Cloud
- Node JS
- PHP
- Python
- C#
- Go
- JavaScript
- Ruby
- Java
Create a Cloud KMS HMAC key
Create a new key in Cloud KMS for HMAC operations.
- Cloud Key Management Service
- Google Cloud
- Python
- JavaScript
- PHP
- Ruby
- Java
- Go
- C#
- Node JS
Encrypt with an asymmetric key
Encrypt plaintext using the public key portion of an asymmetric key.
- Cloud Key Management Service
- Google Cloud
- Java
- Ruby
- PHP
- Go
- Python
- Node JS
- C#
- JavaScript
List key rings
List key rings.
- Cloud Key Management Service
- Google Cloud
- Go
- C#
- Python
- Node JS
- Java
- PHP
- Ruby
- JavaScript
Create an asymmetric signing key
Create an asymmetric signing key.
- Cloud Key Management Service
- Google Cloud
- Node JS
- PHP
- Python
- C#
- Go
- JavaScript
- Ruby
- Java
Get random bytes from an HSM
Retrieve random bytes from the random number generator in Cloud HSM.
- Cloud Key Management Service
- Google Cloud
- Java
- C#
- Ruby
- Go
- Node JS
- Python
- PHP
- JavaScript
Remove an IAM member from a resource
Remove an IAM member from a resource.
- Google Cloud
- Cloud Key Management Service
- C#
- Java
- Node JS
- JavaScript
- Ruby
- Go
- PHP
- Python
Create an HSM key
Create a Cloud HSM key on the specified key ring and location.
- Google Cloud
- Cloud Key Management Service
- Node JS
- Java
- JavaScript
- PHP
- Go
- Ruby
- Python
- C#
Create an import job
Create a new import job in Cloud KMS.
- Google Cloud
- Cloud Key Management Service
- Python
- Go
- JavaScript
- Java
- Node JS
Verify a MAC signature
Verify the signature of data from an HMAC key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- Go
- Ruby
- PHP
- Node JS
- C#
- Java
- Python
Check import job
Check the state of an import job in Cloud KMS.
- Google Cloud
- Cloud Key Management Service
- Python
- Go
- JavaScript
- Java
- Node JS
Get a key version's attestation
Get an HSM-backend key's attestation.
- Google Cloud
- Cloud Key Management Service
- Ruby
- Java
- JavaScript
- PHP
- C#
- Node JS
- Python
- Go
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
- PHP
- Node JS
- JavaScript
- Java
- Go
- Ruby
- C#
- Python
Create a key for import
Set up an empty key for importing your own crypto key.
- Cloud Key Management Service
- Google Cloud
- JavaScript
- Go
- Java
- Python
- Node JS
Update labels on an existing key
Update labels on an existing key.
- Cloud Key Management Service
- Google Cloud
- Go
- JavaScript
- Node JS
- Python
- Java
- C#
- Ruby
- PHP
Create an asymmetric decryption key
Create an asymmetric decryption key.
- Google Cloud
- Cloud Key Management Service
- JavaScript
- Python
- Java
- Go
- PHP
- Node JS
- C#
- Ruby