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

Returning strings when bytes are needed #17

Closed
MrManiak opened this issue Aug 7, 2016 · 2 comments
Closed

Returning strings when bytes are needed #17

MrManiak opened this issue Aug 7, 2016 · 2 comments

Comments

@MrManiak
Copy link

MrManiak commented Aug 7, 2016

I don't know what I'm doing wrong but I've been fixing str/bytes type inversions for an hour now. In this case, I'm not sure what to change to get it working. I 've got the encrypt.dll from some map's github.

This is my traceback:

Traceback (most recent call last):
  File "pokecli.py", line 133, in <module>
    main()
  File "pokecli.py", line 128, in main
    response_dict = api.get_map_objects(latitude =position[0], longitude = position[1], since_timestamp_ms = timestamps, cell_id = cell_ids)
  File "C:\Users\MrManiak\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pgoapi\pgoapi.py", line 121, in function
    return request.call()
  File "C:\Users\MrManiak\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pgoapi\pgoapi.py", line 219, in call
    response = request.request(self._api_endpoint, self._req_method_list, self.get_position())
  File "C:\Users\MrManiak\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pgoapi\rpc_api.py", line 126, in request
    request_proto = self._build_main_request(subrequests, player_position)
  File "C:\Users\MrManiak\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pgoapi\rpc_api.py", line 212, in _build_main_request
    u6.unknown2.unknown1 = self._generate_signature(signature_proto, self._signature_lib)
  File "C:\Users\MrManiak\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pgoapi\rpc_api.py", line 239, in _generate_signature
    signature = b''.join(map(chr, output))
TypeError: sequence item 0: expected a bytes-like object, str found

And this is the code from rpc_api.py

def _generate_signature(self, signature_plain, lib_path = "encrypt.so"):
        lib = ctypes.cdll.LoadLibrary(lib_path)
        lib.argtypes = [ctypes.c_char_p, ctypes.c_size_t, ctypes.c_char_p, ctypes.c_size_t, ctypes.POINTER(ctypes.c_ubyte), ctypes.POINTER(ctypes.c_size_t)] 
        lib.restype  = ctypes.c_int

        iv = os.urandom(32)

        output_size = ctypes.c_size_t()

        ret = lib.encrypt(signature_plain, len(signature_plain), iv, 32, None, ctypes.byref(output_size))
        output = (ctypes.c_ubyte * output_size.value)()
        ret = lib.encrypt(signature_plain, len(signature_plain), iv, 32, ctypes.byref(output), ctypes.byref(output_size))

        signature = b''.join(map(chr, output)) # line 238
        return signature

I've started learning python an hour ago and the syntax is a little confusing to me. I am running python 3.5 on windows 10 64-bit. I'm posting this here because I think this has to be an issue with the code since I'm just running the pokecli from the last commit.

@pbdeuchler
Copy link
Contributor

fix is here: #11

@wchill
Copy link
Contributor

wchill commented Aug 7, 2016

Fixed.

@wchill wchill closed this as completed Aug 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants