1234567891011121314151617181920212223242526272829303132333435 |
- package util
- import (
- "crypto/md5"
- "encoding/hex"
- "ktogame/enums"
- "time"
- "github.com/ethereum/go-ethereum/crypto"
- )
- func NowTimeString() string {
- tm := time.Now()
- t := tm.Format("2006-01-02 15:04:05")
- return t
- }
- func NowTimeDayString() string {
- tm := time.Now()
- t := tm.Format("2006-01-02")
- return t
- }
- func Md5(str string) string {
- hash := md5.New()
- hash.Write([]byte(str))
- s := hex.EncodeToString(hash.Sum(nil))
- return s
- }
- func Sign(amountStr, addr, timeStr string) string {
- keccakA := crypto.Keccak256([]byte(amountStr), []byte(enums.DIGIT))
- keccakS := crypto.Keccak256(keccakA, []byte(timeStr), []byte(addr))
- return "0x" + hex.EncodeToString(keccakS)
- }
|