Skip to main content
Share Your Experience: Take the 2024 Developer Survey
2 of 2
added 504 characters in body
Manishearth
  • 8.3k
  • 5
  • 37
  • 56

One way is to construct the password from an easy phrase, and remember both the easy phrase and the password itself.

For example, take a short password string. Run SHA-256 on it to get a hash. Now, chop the hash into two halves, and hash each half. Put the two new hashes side by side. Chop this hash into four quarters, hash each one, string them together. Repeat a few more times (you have to remember how many times). Put all of the hashes side by side, and you have a very long, random-looking password. To generate it, one must know the starting seed, and the exact algorithm of generation. The seed can be made easy to remember, and so can the algorithm (the above one isn't too hard to remember)

Note that that's just an example, you need to make your own algorithm, and keep it in your head. Nobody can brute force your head1 (and thus it's impossible for them to figure out your hashing algorithm and they probably won't know that you are using one), so they'll just have to try and brute force your encrypted file directly. With a seemingly random and long password, that is hard.

1 Unless they try to get it via social engineering, which is indeed possible. Simplest thing to do: don't talk about the algorithm to anyone (or the seed string). Understand that you are the only one who needs to know either of these. Additionally, if you are using the password as a password to some site (as opposed to an encryption key for a file), then you should make sure you don't fall for phishing or a similar attack.

Manishearth
  • 8.3k
  • 5
  • 37
  • 56