Created
December 24, 2015 11:17
-
-
Save rajesh-gonuguntla/48492b2c7cfa0a40fa32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var crypto = require("crypto"); | |
module.exports = function(method, path, bucket, accesskey, secretkey){ | |
var now = new Date().toUTCString(); | |
var returnChar = '\n'; | |
var strToSign = unescape(encodeURIComponent(method + returnChar + | |
returnChar + returnChar + returnChar + 'x-amz-date:' + now + | |
returnChar + path+bucket)); | |
var hmac = crypto.createHmac('sha1', secretkey); | |
hmac.setEncoding('base64'); | |
hmac.write(strToSign); | |
hmac.end(); | |
var hash = hmac.read(); | |
return "AWS " + accesskey + ":" + hash; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment