Skip to content

Commit

Permalink
Fix hashing of some coordinates
Browse files Browse the repository at this point in the history
Convert floats to uint64 to avoid rounding errors with the hashed
coordinates.
  • Loading branch information
Noctem committed Mar 16, 2017
1 parent 8fce12e commit f528632
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion aiopogo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging

__title__ = 'aiopogo'
__version__ = '1.5.0'
__version__ = '1.5.1'
__author__ = 'David Christenson'
__license__ = 'MIT License'
__copyright__ = 'Copyright (c) 2017 David Christenson <https://github.com/Noctem>'
Expand Down
11 changes: 6 additions & 5 deletions aiopogo/hash_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from itertools import cycle
from time import time
from logging import getLogger
from struct import pack, unpack

from aiohttp import ClientSession, ClientError, DisconnectedError, HttpProcessingError

Expand All @@ -13,7 +14,7 @@
try:
import ujson as json

jargs = {'double_precision': 17, 'escape_forward_slashes': False}
jargs = {'escape_forward_slashes': False}
jexc = ValueError
except ImportError:
import json
Expand All @@ -24,7 +25,7 @@


class HashServer:
endpoint = "https://pokehash.buddyauth.com/api/v127_4/hash"
endpoint = "http://pokehash.buddyauth.com/api/v127_4/hash"
_session = None
multi = False
loop = get_event_loop()
Expand Down Expand Up @@ -55,9 +56,9 @@ async def hash(self, timestamp, latitude, longitude, accuracy, authticket, sessi

payload = {
'Timestamp': timestamp,
'Latitude': latitude,
'Longitude': longitude,
'Altitude': accuracy,
'Latitude64': unpack('<q', pack('<d', latitude))[0],
'Longitude64': unpack('<q', pack('<d', longitude))[0],
'Accuracy64': unpack('<q', pack('<d', accuracy))[0],
'AuthTicket': b64encode(authticket),
'SessionData': b64encode(sessiondata),
'Requests': tuple(b64encode(x.SerializeToString()) for x in requests)
Expand Down

0 comments on commit f528632

Please sign in to comment.