Encrypting Secret Data - List of dictionaries

What I’m trying to do:
Hello Dear Forumers

Mary Christmas and Happy New Year !

I am trying to save List of dictionaries to Data base with Simple object column using Encrypting Secret Data

but

I am getting this error message

anvil.server.InternalError: Internal server error: 84b3817d5f0f

Is it possible to make Encrypting Secret Data of List of Dictioanries in Anvil?

Thank you in advance for your answer !

Internal server errors are usually errors that the Anvil staff needs to investigate. It helps them if you can create a minimal app that shows the error and post the clone link.

2 Likes

Thank you, Jay,

Just a little question - is it possible technically to encrypting a List of dictionaries and then to put to Simple object column in database?

List = [{key:value},{key1:value1},{key2:value2}]
anvil.secrets.encrypt_with_key('encryption_key',List)

A simple object column is used to hold structured data that can be stored as a JSON string. An encrypted string is just a string, it is not JSON. You might as well hold the encrypted string in a string column, a simple object column is overkill.

anvil.secrets.encrypt_with_key is, as far as I can tell, intended to convert a plaintext string into an encrypted string. You’re passing a list in. I don’t know if that’s supported or not, but you can experiment with that by printing out the result, trying to decrypt the result to see what you get out of it, etc.

1 Like

I understand - it is impossible
Thank you very much, Jay !

Not impossible, you just need more steps. If you need a plaintext string to encrypt, you can use Python’s JSON module to convert your list into a JSON string. Then you can encrypt the string.

1 Like

Vau ! I should try - will let you know result later on

Jay it is working - Thank you !

2 Likes