amazon web services - How can I convert bytes received in an AWS error message into something readable in Javascript? -
i'm trying debug wrong signature calculation when accessing amazon s3 via javascript. aws returns xml document 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 read these bytes (i'm sitting on debugging long, i'm getting desperate guess...).
currently i'm playing around in node, things like:
console.log(new buffer([41 57 53 34]).tostring("utf8"))
i'm getting nowhere.
question:
there way convert these bytes might me understand or find out why 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
try this
var s = "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"; var array = s.split(" ").map(function(n) { return number.parseint(n, 16); }); var message = string.fromcharcode.apply(null, array);
Comments
Post a Comment