mirror of
https://github.com/fumiama/tienyik.git
synced 2026-06-04 23:10:26 +08:00
32 lines
475 B
Go
32 lines
475 B
Go
package tienyik
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
"io"
|
|
"strings"
|
|
)
|
|
|
|
const Version = "103010001"
|
|
|
|
const (
|
|
DeviceTypePC = "25"
|
|
DeviceTypeMAC = "45"
|
|
DeviceTypeWEB = "60"
|
|
)
|
|
|
|
const (
|
|
AppModelTOC = "1"
|
|
AppModelTOB = "2"
|
|
AppModelPHONE = "3"
|
|
)
|
|
|
|
func NewDeviceCode() string {
|
|
sb := &strings.Builder{}
|
|
sb.WriteString("web_")
|
|
enc := base64.NewEncoder(base64.RawURLEncoding, sb)
|
|
io.CopyN(enc, rand.Reader, (32/6+1)*8)
|
|
enc.Close()
|
|
return sb.String()[:4+32]
|
|
}
|