Encryption in Anvil

Anvil has some great, built in features (including password management) but for the sake of not retrofitting all of my code just to deploy on Anvil, I’m sticking to some of my old habits.

To that end I need to be able to read encrypted info (with bycrpt) and decrypt them. However Anvil is giving me some voodoo I cannot understand.

This pastebin has my standard encrypt/decrypt function in a class I call Toolbox: https://pastebin.com/tR2Ln2a6. It’s straight forward. It depends on Python 3.x. Also I couldn’t get pycrypto to work so I use cryptodome. But it’s a drop in replacement.

In anvil, I have created this bycrypt_test app and the clone link is: https://anvil.works/ide#clone:UET6MRMJW6V3IZ7H=VKAKQUMB4BZAORM2FLU3YNXU. The Toolbox class is identical, but it depends on whatever dependencies anvil uses. It works fine until we reach this line in the encrypt method

b64_cipher = base64.b64encode( block_and_cipher ) 

Does anyone know what I would have to change in order to get it to work with Anvil?

I took a quick look at the clone. The exact bug was not immediately clear, although I confess I have not used cryptodome myself.

All that being said, if you are content letting the data sit in the app, Anvil does feature encryption at rest. An overview is given here: it is pretty simple to implement:

I appreciate the response, but unfortunately that introduces two problems. A) I am then dependent on Anvil for something I really rather handle internally. B) It leaves me in the same situation as originally where I need to rewrite code. Using anvil secrets would mean less work.

Thanks anyway