-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Following the Full Setup instructions from the repo's main README, and after running:
echo "SECRET_KEY = \"$(python -c 'import os;print(os.urandom(32).hex())')\"" >> lms/lmsweb/config.py
I'm getting:
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'str' object has no attribute 'hex'
Not a Pythonista, please excuse if this is kid-level stuff, I'm just debugging by writing this down.
I'm told Python versions matter, and so I'm running (on an AWS EC2 instance):
Python 2.7.17 [GCC 7.5.0] on linux2
Which implies CPython, I suppose (but that's just me twiddling my thumbs in the air now).
Anywho, looking at the docs for os.urandom(32)
for Python 2.7.18 here implies that i should be getting 32 bytes of random data when running that function, and indeed I do when I try to do that in the REPL:
>>> os.urandom(32)
'\x9e\xf70FV\xd3m=4!2\xad\x7f\xcaD-\\\xf5"7\xb6\x9cp8\x88\xf0\x9dx\xf6\xa1\xd0\xd6'
However, chaining hex()
to the function makes Python not happy:
>>> os.urandom(32).hex()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'hex'
I assume the reason why we're using os.urandom()
instead of using uuid.uuid4()
or one of the other uuid
variants has to do with providing a secret key that is cryptographically secure?
Didn't open a PR yet since I wasn't sure whether that's needed, and also I could be missing something basic.
@gal432 I think that's your area, correct?
BTW - actual SECRET_KEY
line with uuid
instead of urandom
:
echo "SECRET_KEY = \"$(python -c 'import uuid;print(uuid.uuid4().hex)')\"" >> lms/lmsweb/config.py