1 Star 0 Fork 0

Stefan / xgameCommon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
only_v3.go 856 Bytes
一键复制 编辑 原始数据 按行查看 历史
Stefan 提交于 2020-05-09 19:48 . add common file.
package utls
import (
"crypto/md5"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"strconv"
"strings"
)
//create 32bit md5 string
func GetMd5String(s string, upper bool, half bool) string {
h := md5.New()
h.Write([]byte(s))
result := hex.EncodeToString(h.Sum(nil))
if upper == true {
result = strings.ToUpper(result)
}
if half == true {
result = result[8:24]
}
return result
}
//use rand number create Guid string
func NewOnly_v3() string {
b := make([]byte, 48)
if _, err := rand.Read(b); err != nil {
return ""
}
return GetMd5String(base64.URLEncoding.EncodeToString(b), true, false)
}
func NewInt64_v3() (id int64) {
sid := NewOnly_v3()
if len(sid) == 0 {
return
}
val, err := strconv.Atoi(sid)
if err != nil {
panic(err)
return
}
id = int64(val)
return
}
func NewString_v3() string {
return NewOnly_v3()
}
Go
1
https://gitee.com/emmm_admin/xgameCommon.git
git@gitee.com:emmm_admin/xgameCommon.git
emmm_admin
xgameCommon
xgameCommon
v0.0.5

搜索帮助