쿠폰 이름 해시 로직 변경
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package coupon
|
package coupon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -41,8 +42,12 @@ func DisolveCouponCode(code string) (round string, key string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MakeCouponRoundHash(name string) (hash string, roundNumber uint32) {
|
func MakeCouponRoundHash(name string) (hash string, roundNumber uint32) {
|
||||||
|
m5 := md5.New()
|
||||||
|
m5.Write([]byte(name))
|
||||||
|
hashbt := m5.Sum(nil)
|
||||||
|
|
||||||
roundbt := make([]byte, 8)
|
roundbt := make([]byte, 8)
|
||||||
copy(roundbt, []byte(strings.ToLower(name)))
|
copy(roundbt, hashbt[:8])
|
||||||
|
|
||||||
roundseed := int64(binary.BigEndian.Uint64(roundbt))
|
roundseed := int64(binary.BigEndian.Uint64(roundbt))
|
||||||
roundhash := make([]byte, 4)
|
roundhash := make([]byte, 4)
|
||||||
|
|||||||
Reference in New Issue
Block a user