I'm trying to debug an wrong signature calculation when accessing Amazon S3 via JavaScript. AWS returns an XML document which includes:
<StringToSignBytes>41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 31 35 30 34 32 35 54 31 36 32 33 30 36 5a 0a 32 30 31 35 30 34 32 35 2f 65 75 2d 77 65 73 74 2d 31 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 35 33 32 62 61 65 37 62 39 35 66 65 61 62 36 38 66 38 65 32 31 65 39 66 33 62 33 64 61 66 32 34 32 66 63 34 64 35 38 65 34 37 39 61 37 39 37 65 38 33 34 36 62 34 30 38 34 33 39 61 30 37 34 65</StringToSignBytes>
I'm wondering how to read these bytes (I'm sitting over debugging for so long, I'm getting desperate I guess...).
Currently I'm playing around in Node, but with things like:
console.log(new Buffer([41 57 53 34]).toString("utf8"))
I'm getting really nowhere.
Question:
Is there a way to convert these bytes into something which might help me understand or find out why my request failed.
Thanks
EDIT:
Tried Uint8Array
, throw error (at least something):
function uintToString(uintArray) {
var encodedString = String.fromCharCode.apply(null, uintArray),
decodedString = decodeURIComponent(escape(atob(encodedString)));
return decodedString;
}
var foo = "41 57 53 34 2d 48 4d 41 43 2d 53 48 41 32 35 36 0a 32 30 31 35 30 34 32 35 54 31 36 32 33 30 36 5a 0a 32 30 31 35 30 34 32 35 2f 65 75 2d 77 65 73 74 2d 31 2f 73 33 2f 61 77 73 34 5f 72 65 71 75 65 73 74 0a 35 33 32 62 61 65 37 62 39 35 66 65 61 62 36 38 66 38 65 32 31 65 39 66 33 62 33 64 61 66 32 34 32 66 63 34 64 35 38 65 34 37 39 61 37 39 37 65 38 33 34 36 62 34 30 38 34 33 39 61 30 37 34 65".split(" ");
xxx = new Uint8Array(foo);
uintToString(xxx);
// > string contains invalid character