This topic shows you how to retrieve random bytes from the random number generator in Cloud HSM.
Before you begin
- Grant the
cloudkms.locations.generateRandomBytes
permission in the cloud location(s) where your service will be generating random bytes. You can learn about permissions in Cloud Key Management Service at Permissions and roles.
Generating random bytes
C#
To run this code, first set up a C# development environment and install the Cloud KMS C# SDK.
Go
To run this code, first set up a Go development environment and install the Cloud KMS Go SDK.
Java
To run this code, first set up a Java development environment and install the Cloud KMS Java SDK.
Node.js
To run this code, first set up a Node.js development environment and install the Cloud KMS Node.js SDK.
PHP
To run this code, first learn about using PHP on Google Cloud and install the Cloud KMS PHP SDK.
Python
To run this code, first set up a Python development environment and install the Cloud KMS Python SDK.
Ruby
To run this code, first set up a Ruby development environment and install the Cloud KMS Ruby SDK.
Known limitations
The
GenerateRandomBytes
API call can produce at most 1024 bytes of randomness per call. To generate more bytes of randomness, you can make multiple API calls.The
GenerateRandomBytes
API call is not supported for the Software or External protection levels.