Created
March 25, 2016 04:00
-
-
Save brycefisher/22c0676485ae1da5cf6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Implements the signing example w/out AWS SDK in nodejs. See: | |
// http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html | |
const crypto = require('crypto'); | |
function signingKey(secretAccessKey, region, service, datetime) { | |
var date = datetime.substr(0, 8); | |
var kDate = crypto.createHmac('sha256', 'AWS4' + secretAccessKey).update(date).digest(); | |
var kRegion = crypto.createHmac('sha256', kDate).update(region).digest(); | |
var kService = crypto.createHmac('sha256', kRegion).update(service).digest(); | |
return crypto.createHmac('sha256', kService).update('aws4_request').digest('hex'); | |
} | |
var kSigning = signingKey('wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY','us-east-1','s3','20130524T000000Z'); | |
console.log(kSigning); | |
var stringToSign="AWS4-HMAC-SHA256\n20130524T000000Z\n20130524/us-east-1/s3/aws4_request\ncee3fed04b70f867d036f722359b0b1f2f0e5dc0efadbc082b76c4c60e316455" | |
var signature = crypto.createHmac('sha256', new Buffer(kSigning,'hex')).update(stringToSign).digest('hex'); | |
console.log(signature); | |
c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment