hmacutil

package module
v0.0.0-...-388defc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2019 License: MIT Imports: 8 Imported by: 1

README

Hmacutil

Small HMAC utilities for Golang

Download

go get github.com/tiendung1510/hmacutil

Features

  • Computes HMAC using secret key
  • Hex string encoded
  • Base64 encoded
  • Algorithm supports:
    • MD5
    • SHA1
    • SHA256
    • SHA512

Examples

// Computes HMAC
mac := hmacutil.Encode(hmacutil.SHA256, "secret_key", "data")

// Computes HMAC in hex string encoded
mac := hmacutil.HexStringEncode(hmacutil.SHA256, "secret_key", "data")

// Computes HMAC in base64 encoded
mac := hmacutil.Base64Encode(hmacutil.SHA256, "secret_key", "data")

License

MIT

Documentation

Index

Constants

View Source
const (
	// MD5 algorithm
	MD5 string = "MD5"
	// SHA1 algorithm
	SHA1 string = "SHA1"
	// SHA256 algorithm
	SHA256 string = "SHA256"
	// SHA512 algorithm
	SHA512 string = "SHA512"
)

Variables

This section is empty.

Functions

func Base64Encode

func Base64Encode(algorithm string, key string, data string) string

Base64Encode return HMAC in base64 encoded

func Encode

func Encode(algorithm string, key string, data string) []byte

Encode computes a HMAC using secret key

func HexStringEncode

func HexStringEncode(algorithm string, key string, data string) string

HexStringEncode return HMAC in hex string encoded

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL