title: Why is my hmac key off?
body: <p>I am trying to generate an hmac key for use in an image proxy. I have:</p>
  
  <p><a href="https://play.golang.org/p/fec_N2Nim4" rel="nofollow noreferrer">https://play.golang.org/p/fec_N2Nim4</a></p>
  
  <pre><code>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="
  }
  </code></pre>
  
  <p>This is based off <a href="https://github.com/willnorris/imageproxy#signed-requests" rel="nofollow noreferrer">the package's</a> 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:</p>
  
  <p><a href="http://localhost:8080/500,sXyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg" rel="nofollow noreferrer">http://localhost:8080/500,sXyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg</a></p>
  
  <p>vs what I am getting: </p>
  
  <pre><code>http://localhost:8080/500,XyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg
  </code></pre>