sharedstreets / sharedstreets-python

SharedStreets (Python)
https://sharedstreets.io
MIT License
64 stars 16 forks source link

Use `.hexdigest()` rather than `.digest('hex')`? #2

Closed josiekre closed 6 years ago

josiekre commented 6 years ago

Just digging around in here and testing things out. Looks like you have a node function here rather than the python function.

In index.py

def generateHash(message):
    return hashlib.md5(message).hexdigest()

See hashlib documentation.

DenisCarriere commented 6 years ago

The method you are mentioning does look to be correct Python, it's just written shorthand.

$ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.md5("foo").hexdigest()
'acbd18db4cc2f85cedef654fccc4a4d8'

Returns no Python errors.

josiekre commented 6 years ago

I opened the issue because .digest('hex') produces errors.

$ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.md5("foo").digest('hex')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: digest() takes no arguments (1 given)
DenisCarriere commented 6 years ago

oh! 🤦‍♂️ you are correct!

DenisCarriere commented 6 years ago

The index.py hasn't really been touched (not working).

At the moment the Python library is very minimal until we port over the majority of the code from the NodeJS library (even a bit more to extract from the Java library)