Skip to content

Instantly share code, notes, and snippets.

@ericchiang
Created January 22, 2015 17:03
Show Gist options
  • Save ericchiang/8bd1fb904a37a46274b8 to your computer and use it in GitHub Desktop.
Save ericchiang/8bd1fb904a37a46274b8 to your computer and use it in GitHub Desktop.
Why the do these return different values?
package main
import (
"crypto/hmac"
"crypto/sha1"
"fmt"
)
func main() {
salt := []byte("nJ1m4Cc3")
hasher := hmac.New(sha1.New, salt)
fmt.Printf("%x\n", hasher.Sum(nil))
// f7c0aebfb7db2c15f1945a6b7b5286d173df894d
}
import hashlib
salt = "nJ1m4Cc3"
hasher = hashlib.new("sha1", salt)
print hasher.hexdigest()
# d67c1f445987c52bceb8d6475c30a8b0e9a3365d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment