1
0
mirror of synced 2024-11-28 22:46:02 +03:00
mg-transport-telegram/token.go

18 lines
294 B
Go
Raw Normal View History

package main
import (
"crypto/sha256"
"fmt"
"sync/atomic"
"time"
)
var tokenCounter uint32
// GenerateToken function
func GenerateToken() string {
c := atomic.AddUint32(&tokenCounter, 1)
return fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprintf("%d%d", time.Now().UnixNano(), c))))
}