func ToBinary(hmac []byte) int {
	offset := hmac[len(hmac)-1] & 0xf
	bincode := int(((int(hmac[offset]) & 0x7f) << 24) |
		((int(hmac[offset+1]) & 0xff) << 16) |
		((int(hmac[offset+2]) & 0xff) << 8) |
		((int(hmac[offset+3]) & 0xff) << 0))
	if Debug {
		fmt.Println("----- to_binary -----")
		fmt.Printf("len: %d\n", len(hmac))
		fmt.Printf("offset: %d\n", offset)
		fmt.Printf("bincode: %d\n", bincode)
		fmt.Println("----- to_binary -----")
	}
	return bincode
}
ToBinary returns the bincode as an integer.
package goathgen
import "bytes"
import "crypto/sha1"
import "crypto/hmac"
import "encoding/base32"
import "encoding/binary"
import "encoding/hex"
import "fmt"
import "log"
import "strings"
var Debug = false
func Hotp(secret string, counter int64) []byte {
	buf := new(bytes.Buffer)
	err := binary.Write(buf, binary.BigEndian, counter)
	if err != nil {
		log.Fatal(err)
	}
	encoded := []byte(strings.ToUpper(secret))
	decoded := make([]byte, 64)
	var numBytes int
	numBytes, err = hex.Decode(decoded, encoded)
	if err != nil {
		numBytes, err = base32.StdEncoding.Decode(decoded, encoded)
		if err != nil {
			log.Fatal("The secret must be hex or base32 encoded!")
		}
	}
	mac160 := hmac.New(sha1.New, decoded)
	mac160.Write(buf.Bytes())
	if Debug {
		fmt.Println("----- hotp -----")
		fmt.Printf("counter: %d\n", counter)
		fmt.Printf("encoded secret: %s\n", secret)
		fmt.Printf("encoded array: %v\n", encoded)
		fmt.Printf("encoded len: %v\n", len(encoded))
		fmt.Printf("decoded array: %v\n", decoded)
		fmt.Printf("decoded len: %v\n", len(decoded))
		fmt.Printf("decoded secret: %s\n", decoded[:numBytes])
		fmt.Printf("mac160: %v\n", mac160.Sum(nil))
		fmt.Printf("mac160 len: %v\n", mac160.Size())
		fmt.Println("----- hotp -----")
	}
	return mac160.Sum(nil)
}
func Totp(secret string, timeNow int64, timeStep int64, unixEpoch int64) []byte {
	var timeCounter int64
	timeCounter = (timeNow - unixEpoch) / timeStep
	if Debug {
		fmt.Println("----- totp -----")
		fmt.Printf("timeNow: %d\n", timeNow)
		fmt.Printf("timeStep: %d\n", timeStep)
		fmt.Printf("unixEpoch: %d\n", unixEpoch)
		fmt.Printf("timeCounter: %d\n", timeCounter)
		fmt.Println("----- totp -----")
	}
	return Hotp(secret, timeCounter)
}