Fiddle here:
var canonicalString = 'GET'+'\n'
+'/?a=&b=c'+'\n'
+'application/json'+'\n'
+'\n'
+'Mon, 26 Mar 2007 19:37:58 +0000';
console.log(canonicalString);
canonicalString = CryptoJS.HmacSHA256(canonicalString, 'bar');
console.log(CryptoJS.enc.Base64.stringify(canonicalString));
console.log(btoa(canonicalString.toString()));
I can't understand why the results are different. Where I'm wrong? By the way, the right one should be the btoa()
version.