reworked sharecode return
This commit is contained in:
@@ -9,7 +9,8 @@ import (
|
||||
)
|
||||
|
||||
//goland:noinspection SpellCheckingInspection
|
||||
var DICT = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
|
||||
const Base57Chars = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
|
||||
|
||||
var sharecodeRexEx = regexp.MustCompile(`^CSGO(?:-?\w{5}){5}$`)
|
||||
|
||||
func DecodeSharecode(code string) (matchID, outcomeID uint64, tokenID uint16, err error) {
|
||||
@@ -21,11 +22,11 @@ func DecodeSharecode(code string) (matchID, outcomeID uint64, tokenID uint16, er
|
||||
|
||||
chars := ReverseString(strings.Split(cleanCode, ""))
|
||||
bigInt := new(big.Int)
|
||||
dictLenBig := big.NewInt(int64(len(DICT)))
|
||||
dictLenBig := big.NewInt(int64(len(Base57Chars)))
|
||||
|
||||
for _, c := range chars {
|
||||
bigInt.Mul(bigInt, dictLenBig)
|
||||
bigInt.Add(bigInt, big.NewInt(int64(strings.Index(DICT, c))))
|
||||
bigInt.Add(bigInt, big.NewInt(int64(strings.Index(Base57Chars, c))))
|
||||
}
|
||||
|
||||
if bigInt.BitLen() > 144 { //nolint:gomnd
|
||||
|
Reference in New Issue
Block a user