Good morning, I have a MySQL (version 5.0.5 running on Ubuntu 8.04) database containing encrypted fields (the encryption was done using mysql's AES_ENCRYPT). The database is normally accessed by an application written in C++ and Qt. However, I also need to access the database thru a web server and I am getting started with django (1.0).
The encryption key is 16 characters long, and the encrypted fields are defined as VARBINARY(64) in MySQL. I have a djando view where I want to display the decrypted data. The decryption is performed by Python (version 2.5.2) using the library Crypto.Cipher (from Crypto.Cipher import AES). Of course I use the same key in both applications. I do have the following issues: - It appears that I can only effectively encypt/decrypt the data using the paired method, ie. using AES_DECRYPT() where data was encrypted using the MySQL method, and decrypt the data where the encryption was done by Python. If I tried to use AES_DECRYPT on data encrypted by the python code, AES_DECRYPT() returns NULL. - Decrypting data (read from MySQL) using the library Crypto.Cipher (from Crypto.Cipher import AES), the decrypted sting is padded to a length of 16 (or multiple of). For example decryptString: decryptedStr = Deborah, length of string = 16 Subject's firstName = Deborah Character (i = 0) 68 Character (i = 1) 101 Character (i = 2) 98 Character (i = 3) 111 Character (i = 4) 114 Character (i = 5) 97 Character (i = 6) 104 Character (i = 7) 9 Character (i = 8) 9 Character (i = 9) 9 Character (i = 10) 9 Character (i = 11) 9 Character (i = 12) 9 Character (i = 13) 9 Character (i = 14) 9 Character (i = 15) 9 In the case above, the string is padded with chr(9), but other strings are padded with LF, or something else. The python code is listed here def decryptString( strToDecrypt): aesObject = AES.new( 'Example of a key', AES.MODE_ECB) decryptedStr = aesObject.decrypt( strToDecrypt) print "decryptString: decryptedStr = ", decryptedStr, " length of string = ", len( decryptedStr); return decryptedStr Any suggestions on how I can mix the encryption/decryption of values using these two applications? Or is it possible for django to use MySQL functions such as AES_ENCRYPT/AES_DECRYPT in a query? Thanks Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---