GenerateRandom
Returns a random byte string that is cryptographically secure.
For more information about entropy and random number generation, see the AWS Key Management Service Cryptographic Details whitepaper.
Request Syntax
{
"NumberOfBytes": number
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
Note
In the following list, the required parameters are described first.
- NumberOfBytes
-
The length of the byte string.
Type: Integer
Valid Range: Minimum value of 1. Maximum value of 1024.
Required: No
Response Syntax
{
"Plaintext": blob
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- Plaintext
-
The random byte string. When you use the HTTP API or the AWS CLI, the value is Base64-encoded. Otherwise, it is not encoded.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 4096.
Errors
For information about the errors that are common to all actions, see Common Errors.
- DependencyTimeoutException
-
The system timed out while trying to fulfill the request. The request can be retried.
HTTP Status Code: 500
- KMSInternalException
-
The request was rejected because an internal exception occurred. The request can be retried.
HTTP Status Code: 400
Examples
Example Request
The following example is formatted for legibility.
CopyPOST / HTTP/1.1 Host: kms.us-east-2.amazonaws.com Content-Length: 21 X-Amz-Target: TrentService.GenerateRandom X-Amz-Date: 20161114T215101Z Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\ Credential=AKIAI44QH8DHBEXAMPLE/20161114/us-east-2/kms/aws4_request,\ SignedHeaders=content-type;host;x-amz-date;x-amz-target,\ Signature=e3a0cfdbfb71fae5c89e422ad8322b6a44aed85bf68e3d11f3f315bbaa82ad22 {"NumberOfBytes": 32}
Example Response
CopyHTTP/1.1 200 OK Server: Server Date: Mon, 14 Nov 2016 21:51:02 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 60 Connection: keep-alive x-amzn-RequestId: 6f79b0ad-aab4-11e6-971f-0f7b7e5b6782 {"Plaintext":"+Q2hxK6OBuU6K6ZIIBucFMCW2NJkhiSWDySSQyWp9zA="}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following:


