gototp.go
func (totp *TOTP) ForPeriod(period int64) int32 {
	data := int_to_bytestring(period)

	hmacHash := hmac.New(sha1.New, totp.key)
	hmacHash.Write(data)
	digest := hmacHash.Sum(nil)
	offset := int(digest[19] & 0xf)
	code := int32(digest[offset]&0x7f)<<24 |
		int32(digest[offset+1]&0xff)<<16 |
		int32(digest[offset+2]&0xff)<<8 |
		int32(digest[offset+3]&0xff)

	code = int32(int64(code) % int64(math.Pow10(totp.Digits)))
	return code
}
func (totp *TOTP) ForPeriod(period int64) int32 {
	data := int_to_bytestring(period)

	hmacHash := hmac.New(sha1.New, totp.key)
	hmacHash.Write(data)
	digest := hmacHash.Sum(nil)
	offset := int(digest[19] & 0xf)
	code := int32(digest[offset]&0x7f)<<24 |
		int32(digest[offset+1]&0xff)<<16 |
		int32(digest[offset+2]&0xff)<<8 |
		int32(digest[offset+3]&0xff)

	code = int32(int64(code) % int64(math.Pow10(totp.Digits)))
	return code
}
// Return the time-based OTP for the given period.