File: sign.go

package info (click to toggle)
golang-github-adroll-goamz 0.0~git20150909.0.74fd457-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,476 kB
  • ctags: 2,443
  • sloc: makefile: 41
file content (22 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package mturk

import (
	"crypto/hmac"
	"crypto/sha1"
	"encoding/base64"
	"github.com/AdRoll/goamz/aws"
)

var b64 = base64.StdEncoding

// ----------------------------------------------------------------------------
// Mechanical Turk signing (http://goo.gl/wrzfn)
func sign(auth aws.Auth, service, method, timestamp string, params map[string]string) {
	payload := service + method + timestamp
	hash := hmac.New(sha1.New, []byte(auth.SecretKey))
	hash.Write([]byte(payload))
	signature := make([]byte, b64.EncodedLen(hash.Size()))
	b64.Encode(signature, hash.Sum(nil))

	params["Signature"] = string(signature)
}