Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Update utilities.py #3

Merged
merged 1 commit into from
Aug 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pgoapi/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time
import struct
import logging
import xxhash

from json import JSONEncoder
from binascii import unhexlify
Expand Down Expand Up @@ -155,4 +156,24 @@ def long_to_bytes (val, endianness='big'):
# see http://stackoverflow.com/a/931095/309233
s = s[::-1]

return s
return s


def generateLocation1(authticket, lat, lng, alt): #u10
firstHash = xxhash.xxh32(bytearray(authticket), seed=0x1B845238).intdigest() #Hashing the auth ticket using static seed 0x1B845238
locationBytes = bytearray([lat,lng,alt]) #Lat, long and alt as a double
locationHash = xxhash.xxh32(locationBytes, seed=firstHash).intdigest() #hash of location using the hashed auth ticket as seed
return locationHash

def generateLocation2(lat, lng, alt): #u20
locationBytes = bytearray([lat,lng,alt])
locationHash = xxhash.xxh32(locationBytes, seed=0x1B845238).intdigest() #Hash of location using static seed 0x1B845238
return locationHash

def generateRequests(requests): #u24
firstHash = xxhash.xxh64(bytearray(authticket), seed=0x1B845238).intdigest() #Hashing the auth ticket using static seed 0x1B845238
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authticket is not defined here, did you mean to pass it as an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

hashList = [] #Leaving as a list for now
for req in requests:
hashArray.add(xxhash.xxh64(bytearray(req), seed=firstHash).intdigest() #Hash each request with the hashed auth ticket as seed
hashArray = array(I, hashList) #Convert the list to an array
return hashArray