I am trying to generate an hmac key for use in an image proxy. I have:
https://play.golang.org/p/fec_N2Nim4
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
)
func main() {
mac := hmac.New(sha256.New, []byte("secret key"))
mac.Write([]byte("https://octodex.github.com/images/codercat.jpg"))
want := mac.Sum(nil)
fmt.Println("result: ",base64.URLEncoding.EncodeToString(want)) // expect "sXyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY="
}
This is based off the package's recommended formula for generating the key as well as other methods I have tried, which all result in the same key. The url given in the example, however, has an "s" prepended to the front:
vs what I am getting:
http://localhost:8080/500,XyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg