diff --git a/coupon/helper.go b/coupon/helper.go index 768fe7b..1eeab02 100644 --- a/coupon/helper.go +++ b/coupon/helper.go @@ -1,6 +1,7 @@ package coupon import ( + "crypto/md5" "encoding/binary" "encoding/hex" "math/rand" @@ -41,8 +42,12 @@ func DisolveCouponCode(code string) (round string, key string) { } func MakeCouponRoundHash(name string) (hash string, roundNumber uint32) { + m5 := md5.New() + m5.Write([]byte(name)) + hashbt := m5.Sum(nil) + roundbt := make([]byte, 8) - copy(roundbt, []byte(strings.ToLower(name))) + copy(roundbt, hashbt[:8]) roundseed := int64(binary.BigEndian.Uint64(roundbt)) roundhash := make([]byte, 4)