Documentation ¶
Overview ¶
Package hmac implements the Keyed-Hash Message Authentication Code (HMAC) as defined in U.S. Federal Information Processing Standards Publication 198. An HMAC is a cryptographic hash that uses a key to sign a message. The receiver verifies the hash by recomputing it using the same key.
Index ¶
- func Md5(src, key []byte) ([]byte, error)
- func Md5Hex(src, key string) (string, error)
- func Md5Sum(src, key, sum []byte) ([]byte, error)
- func Md5SumHex(src, key, sum string) (string, error)
- func Sha1(src, key []byte) ([]byte, error)
- func Sha1Hex(src, key string) (string, error)
- func Sha1Sum(src, key, sum []byte) ([]byte, error)
- func Sha1SumHex(src, key, sum string) (string, error)
- func Sha256(src, key []byte) ([]byte, error)
- func Sha256Hex(src, key string) (string, error)
- func Sha256Sum(src, key, sum []byte) ([]byte, error)
- func Sha256SumHex(src, key, sum string) (string, error)
- func Sha512(src, key []byte) ([]byte, error)
- func Sha512Hex(src, key string) (string, error)
- func Sha512Sum(src, key, sum []byte) ([]byte, error)
- func Sha512SumHex(src, key, sum string) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Md5 ¶
Md5 calculates the MD5 digest and returns the value as a byte[].
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Md5([]byte("goyy"), []byte("key")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: aa35a3db5523705942e0d117faf76ed5
func Md5Hex ¶
Md5Hex calculates the MD5 digest and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Md5Hex("goyy", "key") fmt.Println(dst) }
Output: aa35a3db5523705942e0d117faf76ed5
func Md5Sum ¶
Md5Sum calculates the MD5 digest to sum and returns the resulting slice.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Md5Sum([]byte("goyy"), []byte("key"), []byte("goyy:")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 676f79793aaa35a3db5523705942e0d117faf76ed5
func Md5SumHex ¶
Md5SumHex calculates the MD5 digest to sum and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Md5SumHex("goyy", "key", "goyy:") fmt.Println(dst) }
Output: 676f79793aaa35a3db5523705942e0d117faf76ed5
func Sha1 ¶
Sha1 calculates the SHA-1 digest and returns the value as a byte[].
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha1([]byte("goyy"), []byte("key")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 221f50c7d0d8f13e160be5660a1a27d5bb18861c
func Sha1Hex ¶
Sha1Hex calculates the SHA-1 digest and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha1Hex("goyy", "key") fmt.Println(dst) }
Output: 221f50c7d0d8f13e160be5660a1a27d5bb18861c
func Sha1Sum ¶
Sha1Sum calculates the SHA-1 digest to sum and returns the resulting slice.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha1Sum([]byte("goyy"), []byte("key"), []byte("goyy:")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 676f79793a221f50c7d0d8f13e160be5660a1a27d5bb18861c
func Sha1SumHex ¶
Sha1SumHex calculates the SHA-1 digest to sum and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha1SumHex("goyy", "key", "goyy:") fmt.Println(dst) }
Output: 676f79793a221f50c7d0d8f13e160be5660a1a27d5bb18861c
func Sha256 ¶
Sha256 calculates the SHA-256 digest and returns the value as a byte[].
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha256([]byte("goyy"), []byte("key")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 840f83ba7e39cc809ea5ff9829da11070b21aaf4f306a356d0eb782a7c09f54a
func Sha256Hex ¶
Sha256Hex calculates the SHA-256 digest and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha256Hex("goyy", "key") fmt.Println(dst) }
Output: 840f83ba7e39cc809ea5ff9829da11070b21aaf4f306a356d0eb782a7c09f54a
func Sha256Sum ¶
Sha256Sum calculates the SHA-256 digest to sum and returns the resulting slice.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha256Sum([]byte("goyy"), []byte("key"), []byte("goyy:")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 676f79793a840f83ba7e39cc809ea5ff9829da11070b21aaf4f306a356d0eb782a7c09f54a
func Sha256SumHex ¶
Sha256SumHex calculates the SHA-256 digest to sum and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha256SumHex("goyy", "key", "goyy:") fmt.Println(dst) }
Output: 676f79793a840f83ba7e39cc809ea5ff9829da11070b21aaf4f306a356d0eb782a7c09f54a
func Sha512 ¶
Sha512 calculates the SHA-512 digest and returns the value as a byte[].
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha512([]byte("goyy"), []byte("key")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: ecaefb579a65c35352558f88a6b691199884784bfd35deb997ec1e40d20cc99d49d586a59e7b4c6a6e8c250e8dd16262547e991bd9e32f5da722f071230308c3
func Sha512Hex ¶
Sha512Hex calculates the SHA-512 digest and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha512Hex("goyy", "key") fmt.Println(dst) }
Output: ecaefb579a65c35352558f88a6b691199884784bfd35deb997ec1e40d20cc99d49d586a59e7b4c6a6e8c250e8dd16262547e991bd9e32f5da722f071230308c3
func Sha512Sum ¶
Sha512Sum calculates the SHA-512 digest to sum and returns the resulting slice.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha512Sum([]byte("goyy"), []byte("key"), []byte("goyy:")) fmt.Println(fmt.Sprintf("%x", dst)) }
Output: 676f79793aecaefb579a65c35352558f88a6b691199884784bfd35deb997ec1e40d20cc99d49d586a59e7b4c6a6e8c250e8dd16262547e991bd9e32f5da722f071230308c3
func Sha512SumHex ¶
Sha512SumHex calculates the SHA-512 digest to sum and returns the resulting hex string.
Example ¶
package main import ( "fmt" "gopkg.in/goyy/goyy.v0/util/crypto/hmac" ) func main() { dst, _ := hmac.Sha512SumHex("goyy", "key", "goyy:") fmt.Println(dst) }
Output: 676f79793aecaefb579a65c35352558f88a6b691199884784bfd35deb997ec1e40d20cc99d49d586a59e7b4c6a6e8c250e8dd16262547e991bd9e32f5da722f071230308c3
Types ¶
This section is empty.