Hi , Does anyone know how to calculate "aws signat...
# suitescript
a
Hi , Does anyone know how to calculate "aws signature version 4" in suitescript 2.0 . I have tried this code but the signing key appears to be wrong in binary format although it matches with python example provided by aws in hex format but binary format in python is different then suitescript which makes signature different in python(correct signature ) and suitescript 2.0 (Wrong signature).
Copy code
function getSignatureKey(key, dateStamp, regionName, serviceName) {
var kDate = CryptoJS.HmacSHA256(dateStamp, "AWS4" + key);
var kRegion = CryptoJS.HmacSHA256(regionName, kDate);
var kService = CryptoJS.HmacSHA256(serviceName, kRegion);
var kSigning = CryptoJS.HmacSHA256("aws4_request", kService);
return kSigning;
}

signing_key = getSignatureKey(secret_key, datestamp, region, service);

 var signingsha256Data = CryptoJS.HmacSHA256(encodeURI(string_to_sign),signing_key);

 var signature= CryptoJS.enc.Hex.stringify(signingsha256Data);

 log.debug('Calculated signature is ',signature);
@battk any idea about this sir ?
b
crypto generally is too much work
without checking how the aws signature version works, my guess is that you are doing something strange with your inputs
binary are representation of bytes
its usually wrong to represent binary as a utf string since that cant normally represent all bytes
usually crypto libaries allow you to input binary using different encodings like hex or base 64, which you will probably need to do if any of your inputs to your function are binary strings
especially common for keys
a
understood . Thanks