1

How can I encrypt a string of information and put it on a piece of paper and be able to plug that encrypted text back into the algorithm with a password and unlock the information? Is this secure?

schroeder
  • 129,372
  • 55
  • 299
  • 340

2 Answers2

1

Being that you want to use the same password for encryption and decryption, this is symmetric encryption. You can use openssl to do symmetric encryption.

To encrypt the plaintext:

echo -n 'hello world!' | openssl aes-256-cbc -e -salt -pbkdf2 -iter 10000 | base64

It will prompt you for a password, then produce the ciphertext in base64-encoded form, like so:

U2FsdGVkX19e/xfT89w7I5dQqiqd+dNxMu5E868fyWA=

Copy the base-64 encoded ciphertext on the piece of paper. Then, when it comes time to decrypt the ciphertext, use openssl again, like so:

echo -n 'U2FsdGVkX19e/xfT89w7I5dQqiqd+dNxMu5E868fyWA=' | base64 -d | openssl aes-256-cbc -d -salt -pbkdf2 -iter 10000

After entering the correct password, it will produce the plaintext that you started with:

hello world!
mti2935
  • 23,468
  • 2
  • 53
  • 73
  • Thanks... Should I write on the paper what algorithm it uses (aes-256) in case I forget?

    Also, is it safe to store cryptocurrency wallet seeds like this?

    – prestonferry Jan 27 '24 at 14:07
  • Writing the algorithm is a good idea. You might also want to write the above commands as well, as these show how the AES key is derived from the password. I would use extreme caution if encrypting cryptocurrency seeds this way - if an attacker found the paper containing the cyphertext, then there is little to slow him down if he tries to brute-force the password. If you decide to do this, make sure the password is very strong. – mti2935 Jan 27 '24 at 14:50
  • Well I know the password is definitely not in a password list, never been used anywhere else, and I doubt that anyone will be looking through the papers anytime soon... Does this mean anything? – prestonferry Jan 27 '24 at 15:33
  • Only you can evaluate the risk. Of course, the risk will increase with the value of the cryptocurrency that you have assigned to the address. And, the risk will decrease with the amount of entropy of your password. Nowadays, even passwords with 60+ bits of entropy can be cracked in a few days, using just a few thousand dollars worth of equipment. See https://security.stackexchange.com/questions/265805/how-safe-is-a-password-protected-excel-file for more info. – mti2935 Jan 27 '24 at 16:53
  • 1
    So, is your question really "how can I security store my crypto wallet seed?" Because that's a whole different question. – schroeder Jan 29 '24 at 21:53
  • @schroeder I guess that is a better question actually… I wouldn’t say it’s totally different though, because my question was general whereas that would be more direct… – prestonferry Feb 02 '24 at 06:04
  • @mti2935 so I guess it’s only really secure when you have a randomly generated password by what that link seems to be replying… Can you tell me what exactly I can do in my situation, where I want to be able to put that key anywhere and get to it properly with a password I can remember in my head, while being as secure? My goal is to put this on a piece of paper that’s practically impossible (practically, not totally) to brute force without compromising my ability to easily access it… I can explain more if you have any questions… – prestonferry Feb 02 '24 at 06:09
  • There are two things you can do to make this solution more resilient to brute-force attacks: 1) make the password as strong as possible; and 2) use a slow key derivation function (KDF). For 1, see https://proton.me/blog/create-remember-strong-passwords. For 2, a slow KDF (such as Argon2) is intentionally designed to consume lots of resources when run, in order to slow down a brute-force attacker. – mti2935 Feb 02 '24 at 18:43
  • The KDF in the example above uses 10,000 rounds of PBKDF2, which is OK but not great. It will run in a a few milliseconds on a standard desktop PC. Argon2 on the other hand can be tuned to take tens of thousands of times longer to run, which means that it will also slow down even a well-equiped attacker considerably. I tried doing a quick Google search for a command line tool that can be used to do AES encryption using a key derived from a password by Argon2. I was not able to find anything that looked promising immediately, but you might have better luck. – mti2935 Feb 02 '24 at 18:44
0

The principle is that encryption converts from clear text to binary data, then you use any method whatsoever to convert binary data into something that humans find easy to read and write or type, send this to a receiver (if you are the receiver you can just print it and keep the paper), then the receiver converts from human readable to binary, and finally the binary data is decrypted to give the original clear text. The conversion between binary and human readable doesn’t need to be secure whatsoever.

Base-64 encoded text is human readable, but not very human readable. Everything is uppercase and lowercase letters and digits plus two more symbols, all equally likely. This is not how human written text works.

You could create a list of 8192 natural words in your favourite language. Then convert 13 binary bits to one of those words. Send lines of text; each line contains as many words as you like separated by space characters.

gnasher729
  • 2,381
  • 14
  • 17