0

I need something simple, where I can:

  1. encrypt it with a password (salt, everything related)
  2. write it to disk

Then the opposite:

  1. read from disk
  2. decrypt it with my password

Everything I find out there is either not maintained properly, or doesn't have examples, or outdated, or needs 50 lines of code to be used which I have to maintain myself.

I would like to have something as simple as what I do locally on my terminal. I do this on my terminal:

To encrypt:

$ cat data | openssl des3 -salt | dd of=output.des3

To decrypt:

$ dd if=output.des3 | openssl des3 -d -salt

How can I do this in Python in a cross plaform and secure way?

4

1 Answer 1

2

First off, avoid 3DES encryption. It exists only as a stop-gap created because of the panic after regular DES was broken but before people had any reasonable alternative. It's only marginally more secure than plain DES (which is trivially broken) and is horribly inefficient compared to more modern stuff (even Blowfish, which is not much more recent, is faster and more secure).

Now, as far as doing what you're talking about in Python, I would suggest taking a look at Cryptography. It's the de-facto standard for cryptographic operations in Python that aren't explicitly handled by some special purpose module (like the SSL support in the standard library). While I've never done anything directly with it myself, it's used by a wide variety of other projects to get crypto-support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.