As of right now, I am in the process of creating a signature for OAuth 1.0 for Twitter.
Im following this.
I've ran into a small problem at the end.
They have
84 2B 52 99 88 7E 88 7602 12 A0 56 AC 4E C2 EE 16 26 B5 49
And they manage to create
hCtSmYh+iHYCEqBWrE7C7hYmtUk=
Their explanation is to Encode the "binary string" to base64.
I saw in this stackoverflow question that i basically need to decode hex and then encode base64 to get from
84 2B 52 99 88 7E 88 7602 12 A0 56 AC 4E C2 EE 16 26 B5 49
To
hCtSmYh+iHYCEqBWrE7C7hYmtUk=
And it worked in the online calculator, so now I need to implement it to javascript, the Base64 encode works correctly and looks like that:
Buffer.from("ExampleString").toString('base64')
However the Hex Decode seems to be the problem
I got the solution from here.
This is my Hex Decoder
String.prototype.hexDecode = function(){
var j;
var hexes = this.match(/.{1,4}/g) || [];
var back = "";
for(j = 0; j<hexes.length; j++) {
back += String.fromCharCode(parseInt(hexes[j], 16));
}
return back;
}
I get a different string when I use "my" Decoder and the online calculator, any idea?