Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-10 Thread Mike Bayer
the AES library has been updated a bit so I updated the recipes at: https://github.com/sqlalchemy/sqlalchemy/wiki/SymmetricEncryptionClientSide regardless of what encrpytion you are using, for a WHERE clause to work, you need to ensure the encrypt() function produces the same string each time. I

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-10 Thread Mike Bayer
The recipe encrypts the value in the WHERE clause, however it seems like the usage of the libraries in the example is a bit out of date for Python 3. What Python version are you using ? On Thu, Jul 9, 2020, at 1:15 PM, Justvuur wrote: > So there is good news and bad news hehe. > Good news is i

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-10 Thread Simon King
Not in the traditional sense, no. ORDER BY is implemented by the database, and with client-side encryption, the database only ever sees encrypted strings. Simon On Fri, Jul 10, 2020 at 8:41 AM Justin Van Vuuren wrote: > > Also, regarding the client side approach, would one be able to do an order

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-10 Thread Justin Van Vuuren
Also, regarding the client side approach, would one be able to do an order by query? On Thu, 9 Jul 2020 at 21:28, Justvuur wrote: > A, ok ye, I understand, then I prefer client side. > I just need to sort out the encryption then... I'm not too familiar with > encryption algorithms but at the

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread Justvuur
A, ok ye, I understand, then I prefer client side. I just need to sort out the encryption then... I'm not too familiar with encryption algorithms but at the moment its using a text key from a config file and the mode is CBC which I guess is what is generating a different value each time righ

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread 'Jonathan Vanasco' via sqlalchemy
On Thursday, July 9, 2020 at 2:12:36 PM UTC-4, Justvuur wrote: > > I've done some more digging... It seems when I did the search for > "secrets", the text is encrypted and compared to the value in the columns, > That is how client-side encryption works. If you want to search for "secrets", y

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread Justvuur
I've done some more digging... It seems when I did the search for "secrets", the text is encrypted and compared to the value in the columns, see below: SELECT student_form_fields.field_value AS student_form_fields_field_value, student_form_fields.student_id AS student_form_fields_stude

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread Justvuur
So there is good news and bad news hehe. Good news is if I query all the other columns (no encrypted) columns it works. All results are returned correctly and decrypted. Bad news, if I query the encrypted column, nothing is "found". This is my model: class StudentFormField(db.Model): __tablen

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread Mike Bayer
On Thu, Jul 9, 2020, at 4:53 AM, Justvuur wrote: > Hi Mike, > > This is awesome! Yes, I like the client side approach, especially the "Use > TypeDecorator" method. > Is there a specific version of SQLAlchemy I need? TypeDecorator is pretty universal so it should work for any modern version in

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread Justvuur
Hi Mike, This is awesome! Yes, I like the client side approach, especially the "Use TypeDecorator" method. Is there a specific version of SQLAlchemy I need? So with this, I would be able to query/filter an encrypted column and it will automatically perform the decryption to test the column? O

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-08 Thread Mike Bayer
I had just created all-new revised encryption examples on the wiki and apparently I forgot to link them from the index, fixed. Here's two examples showing the general idea of how this can be done: https://github.com/sqlalchemy/sqlalchemy/wiki/SymmetricEncryptionClientSide https://github.com/sql

[sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-08 Thread Justvuur
Hi All, In one or two database tables I need to encrypt/decrypt a couple of columns. These tables/columns already exist in the DB and they already have data in them. What is the best way using SQL Alchemy to add encryption to these tables/columns? It needs to be efficient and the columns need