Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Python just-dice.com verifier, based on the JavaScript verifiers described on the "Fair?" pages at just-dice.com
- #
- # example usage:
- # python just-dice.py ia_zEVRJ_VqfHPDbqGEYm39d6d2yg58_t1brUjO2LwiDBVydO7sKh6Sulw8123ec 7ab7df124145d0fcf931c142aabcca2022f60775d6afa692be114c09ff4408cf 515035004112265853362847 12
- # prints the last 10 lucky numbers, starting with roll 12 since the last randomize, which is this bet: https://just-dice.com/roll/23616559
- import hashlib
- import hmac
- import sys
- # parse command line arguments
- if len(sys.argv) < 5:
- print("usage: python just-dice.py server-seed server-seed-hash client-seed last-roll [roll-count]")
- exit(-1)
- print(sys.argv[1])
- serverSeed = sys.argv[1]
- serverSeedHash = sys.argv[2]
- clientSeed = sys.argv[3]
- lastNonce = int(sys.argv[4])
- nonceCount = 10
- if len(sys.argv) == 6:
- nonceCount = int(sys.argv[5])
- # convert string to binary array
- def str2bin(string):
- return bytes(string, 'latin-1')
- # test server hash
- hash_object = hashlib.sha256(str2bin(serverSeed))
- hash = hash_object.hexdigest()
- if hash == serverSeedHash:
- print('Server secret hash is correct.')
- else:
- print('Server secret hash check failed!')
- # calculate and show lucky numbers
- for nonce in range(lastNonce, lastNonce - nonceCount, -1):
- hash_object = hmac.new(str2bin(serverSeed), str2bin(clientSeed + ":" + str(nonce)), hashlib.sha512)
- hash = hash_object.hexdigest()
- i = 0
- while True:
- if i == 25:
- l3 = hash[-3:]
- l3p = int(l3, 16)
- #print('last 3: ' + l3 + ' as int: ' + l3p)
- roll = l3p / 10000
- break
- else:
- f5 = hash[5 * i : 5 + 5 * i]
- f5p = int(f5, 16)
- #print(f5 + ' as int: ' + f5p);
- if f5p < 1000000:
- roll = f5p / 10000
- break
- i = i + 1
- lucky = ('0' + '{:.4f}'.format(roll))[-7:]
- print(str(nonce) + ": " + lucky)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement