Skip to content

Instantly share code, notes, and snippets.

@jpillora
Last active December 22, 2015 03:09
Show Gist options
  • Save jpillora/6408033 to your computer and use it in GitHub Desktop.
Save jpillora/6408033 to your computer and use it in GitHub Desktop.
S3 Request Signing (generates Authorization headers)
//Performs the signing in the first example of:
// http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html
//Requires:
// http://www.defensivejs.com/djcl/encoding.js
// http://www.defensivejs.com/djcl/hashing.js
var str = "GET\n"+
"\n"+
"\n"+
"Tue, 27 Mar 2007 19:36:42 +0000\n"+
"/johnsmith/photos/puppy.jpg";
var k = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
hashing.hmac_hash = hashing.sha1;
var result = encoding.base64_encode(encoding.hstr2astr(hashing.HMAC(k,str)));
print(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment