App Engine Ndb StringProperty And String Hashes
I'm using PyCrypto for generating secure key hashes. I want to store one or more of the partial keys I generate. Each partial key is in the form \x0f|4\xcc\x02b\xc3\xf8\xb0\xd8\xfc
Solution 1:
Improved Answer:
In this case instead of storing the key as String or Text, you should use a BlobProperty
which stores an uninterpreted byte string.
Original Answer:
To convert bytes (strings) to unicode you use the method decode
. You also need to use an encoding that preserves the original binary data, which is ISO-8859-1. See ISO-8859-1 encoding and binary data preservation
unicode_key = key.decode('iso-8859-1')
bytes_key = unicode_key.encode('iso-8859-1')
Consider also using A TextProperty instead, as StringProperties are indexed.
Post a Comment for "App Engine Ndb StringProperty And String Hashes"