You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
401 B

package main
import (
"fmt"
"github.com/oklog/ulid"
"github.com/rs/xid"
"math/rand"
"strings"
"time"
)
func main(){
//获取主键ID
ak := xid.New()
appKey := ak.String() //新增就生成一个secret
t := time.Now().UTC()
entropy := rand.New(rand.NewSource(t.UnixNano()))
appSecret := strings.ToLower(ulid.MustNew(ulid.Timestamp(t), entropy).String())
fmt.Println(appKey,appSecret)
}