Encrypt export.pkl

Hi everybody,

I was wondering if the file export.pkl for the learner could be encrypted in some way.
fastai.basic_train.load_learner seems to accept pathname and filename only, but is there any other way to give the data as a parameter or give some inputStream?
Then the decryption of export.pkl could be done in some other place.

Thanks.

Hi hcoj

If you can not pipe it into the command you could simple decrypt it to a local file and then use it.

Here is an example of encryption and decryption.
The sha256 is used to create a 64 byte password. The information is from various Internet articles.

import pyAesCrypt

password = “please-use-a-long-and-random-password”

key = hashlib.sha256(str(password).encode(‘utf-8’))

passkey = key.hexdigest()

!echo “Hello my friend 2”>data.txt

encrypt

pyAesCrypt.encryptFile(“data.txt”, “data.txt.aes”, passkey)

decrypt

pyAesCrypt.decryptFile(“data.txt.aes”, “dataout.txt”, passkey)

!cat dataout.txt

Hello my friend 2

Hi Conwyn,
thanks for your idea. But storing the file back unencrypted on my disk - wouldn’t that make any encryption beforehand useless?

Solved: load_learner function takes io.BytesIO stream as second argument as well