Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Hash the payload
attHashedPayload = CryptoEncoding.base64toHex(CryptoDigest.sha256(attBody));
// Format the date
attAmzDate = System.getModule("com.hobbitcloud.aws.date").getAmzDate(new Date().toISOString());
var canonicalUri = "/2013-04-01/hostedzone/" + attHostedZone + "/rrset";
var canonicalQueryString = "";
var canonicalHeaders = 'host:' + attUrl + '\n' +
'x-amz-content-sha256:' + attHashedPayload + '\n' +
'x-amz-date:' + attAmzDate + '\n'
attSignedHeaders = 'host;x-amz-content-sha256;x-amz-date';
// Define the request
var canonicalRequest = attHttpRequestMethod + '\n' + canonicalUri + '\n' + canonicalQueryString + '\n' + canonicalHeaders + '\n' + attSignedHeaders + '\n' + attHashedPayload;
System.log("The canonical request is: " + '\n' + '\n' + canonicalRequest + '\n');
// Hash the request
attCanonicalRequestHash = CryptoEncoding.base64toHex(CryptoDigest.sha256(canonicalRequest));
System.log("The canonical request hash is: " + attCanonicalRequestHash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.