github.com/goplus/yap@v0.8.1/ydb/demo/foo/foo.gop (about) 1 import ( 2 "crypto/hmac" 3 "crypto/sha256" 4 "encoding/base64" 5 "errors" 6 "log" 7 mrand "math/rand" 8 "sort" 9 "strconv" 10 "time" 11 12 "github.com/qiniu/x/stringutil" 13 ) 14 15 var ( 16 ErrNoEmailAndTel = errors.new("no email and telephone") 17 ) 18 19 var ( 20 rnd = mrand.new(mrand.newSource(time.now.unixMicro)) 21 ) 22 23 func Rand() string { 24 return strconv.formatInt(rnd.int63(), 36) 25 } 26 27 func Hs256(pwd, salt string) string { 28 b := hmac.new(sha256.New, []byte(salt)).sum([]byte(pwd)) 29 return base64.RawURLEncoding.encodeToString(b) 30 } 31 32 func Diff(new, old []string) (add, del []string) { 33 sort.strings(new) 34 sort.strings(old) 35 return stringutil.diff(new, old) 36 } 37 38 // Info calls Output to print to the standard logger. 39 // Arguments are handled in the manner of fmt.Println. 40 func Info(args ...any) { 41 log.println(args...) 42 }