django-encrypted-id
django-encrypted-id copied to clipboard
ekey includes $ since version 0.3
Hello, I updated to version 0.3 today. Since then, the ekey has a $ at the beginning.
Example: $C8qooWqMNv8aC2Zrnl7j1A
Python: 2.7 Django: 1.11 django-encrypted-id: 0.3.0
?
The dollar sign has been removed in 0.31. Please update to that.
This will still decrypt older versions, including 0.3 (with dollar sign) and 0.2x (without dollar sign). But the ekey produced will be different.
Is there documentation available - general and for regex?
Hi, version 0.3.0 can not decrypt ekeys from version 0.2.0.
In decode(e, sub_key)
the variable the_id
has the right value, but crc != expected_crc
is true.
@jatinderjit, can you look at this please.
Without this if, keys from version 0.2.0 are also correctly evaluated in 0.3.X.
if version == 0:
expected_crc = binascii.crc32(bytes(the_id)) & 0xffffffff
else:
id_str = str(the_id).encode('utf-8')
expected_crc = binascii.crc32(id_str) & 0xffffffff
Keys from version 0.2.0 return the wrong version in line 84. https://github.com/amitu/django-encrypted-id/blob/master/encrypted_id/init.py#L84
Any updates here?
Hey @wittfabian, sorry for such a late response.
If I understood correctly:
- You generated an encrypted id using version 0.2.0
- And then tried decrypting that encrypted key using version 0.3.x
If this is what you are trying to do, then I couldn't reproduce it.
SECRET_KEY = "34v*r6xdx^4o0_je66&yp48934&p77d3!dvy-8(s(ear3x1yvr"
encode(123, "abc") == "GOX-Z9nNStjer4tMHaeKZw" # Version 0.2.0
encode(123, "abc") == "$F7joJ5OUm1IfKyfjBaO2TA" # Version 0.3.0
encode(123, "abc") == "Rrh_U6BkP01CMZ3r1vYZZQ" # Version 0.3.1, 0.3.2, 0.3.3
decode("GOX-Z9nNStjer4tMHaeKZw", "abc") == 123 # all versions
decode("$F7joJ5OUm1IfKyfjBaO2TA", "abc") == 123 # Version 0.3.0+
decode("Rrh_U6BkP01CMZ3r1vYZZQ", "abc") == 123 # Version 0.3.1+
Each version should be able to decode the keys generated by the previous versions. If this is not working for you, can you please provide some more details so that I can reproduce this?