This is a created article in which the information may have evolved or changed.
Package Mainimport ("Crypto/hmac" "crypto/sha512" "FMT" "StrConv" "Time") type Key struct {gkey Stringskey stringdate func ( ) Int64}const (Gkey = "What") Func main () {K: = &key{gkey:gkey, Date:getdate}b: = HMAC. New (sha512. New, []byte (K.hmac ("Hello World"))) B: = b.sum (nil) Offset: = B[len (B)-1] & 0xfx: = ((int (b[offset+1]) & 0xff) <& Lt 16) | ((int (b[offset+2) & 0xff) << 8) | (int (b[offset+3]) & 0xff) Z: = FMT. Sprint (x 1000000) for Len (z) < 6 {z = fmt. Sprintf ("0%s", Z)}fmt. Println (z)}func (self *key) Hmac (Skey String) string {return FMT. Sprintf ("%s%s%d", Self.gkey, Skey, Self.date ())}func getdate () Int64 {T: = time. Now () format_t: = T.format ("0601021504") unix_t: = T.unix ()-T.unix ()%30num, _: = StrConv. Atoi (format_t) x: = num% 10return unix_t<<uint (x) ^ int64 (num) >>uint (x)}