I am a beginning programmer interested in coding an application of my own to encrypt sensitive files of mine. For example: lists of passwords, bank accounts, Credit Card numbers etc.

I was wondering what would be the easiest encryption algorithms to learn from a purely theoretical point of view?

  • 1
    $\begingroup$ Welcome to Crypto.SE. I assume you've already tried Wikipedia for ideas? The XOR cipher is probably the easiest but it's easy to break if not somehow turned into an OTP. The devil is in the details though. For securing sensitive information I'd suggest using GnuPG or TrueCrypt or any other freely available software (don't roll your own!). Anyway this question might be off-topic as it's a bit subjective and invites list answers. Good luck! $\endgroup$
    – rath
    Aug 8, 2013 at 21:11
  • $\begingroup$ Okay, thanks for the info! I'll try the XOR cipher. $\endgroup$
    – Zagstrug
    Aug 8, 2013 at 21:29
  • 2
    $\begingroup$ Definitely do not roll you own crypto software for you "own use". For learning is fine, but never use it for anything you want to actually be secure. The reason is that there are lots of intricacies when developing crypto software that if not understood could render your crypto solution completely insecure. TrueCrypt or GnuPG are good suggestions. $\endgroup$
    – mikeazo
    Aug 8, 2013 at 22:49
  • 1
    $\begingroup$ Doing this is a good learning exercise, but definitely don't use your software to store your (or worse, other people's) data. $\endgroup$ Aug 9, 2013 at 14:36
  • 1
    $\begingroup$ @rath When people say encrypt (without other knowledge), they probably mean symmetrically encrypt with a password cipher = encrypt(plain, password), plain = decrypt(cipher, password). What simple but secure algorithm would you recommend for this? RC4 is considered weak, so what else? AES (but it doesn't seem to be easily usable with a "password")? Fernet (recommended in an answer of stackoverflow.com/questions/2490334/…)? Anything else? $\endgroup$
    – Basj
    Oct 25, 2019 at 7:43

1 Answer 1


Concerning "As a new programmer...":

Probably you don't know this yet, but as a rule of thumb: Do not use your self-implemented crypto for anything unless you are really an expert in the field. This might seem counter-intuitive for the outside, but anything else has to be considered insecure.

The reason for this is that for most aspects of programming and computer science the average case is the most important one. It is not too important if there is a very unlikely flaw in a system since it probably won't happen anyway. But in crypto, the attacker will exploit this flaw to break the system on purpose. Therefore, not the average case is important, but the worst case. For example, you can find statements like "the probability of the attacker to guess right is no more than $\frac{1}{2^n}$" (worst case estimation).

The above statement is not entirely true, but it depends on the abstraction layer: If you utilize standard implementations of encryption, hash functions, key exchange, TLS, etc... you can use those primitives in a high level protocol and most likely you are "secure".

But if you start writing your own crypto primitives, you will probably overlook something. Even worse, if you start using your primitive in a larger context, there is not only a small problem in a single function... you make the entire system insecure. Security is like a chain, and it breaks with the weakest link, not the "average strength".

Back on topic:

You can implement encryption schemes for practice or to learn something, but I advise heavily against using this.

For practice, this depends largely on your experience as a programmer. For the very start, you might want to consider using historical ciphers like Caesar, Vigenere in order to get comfortable with the principles (they are not secure, tho). If you want to have something more useful, you can implement a stream cipher (XOR cipher with some kind of random number generator). Some public key cryptosystems can be easily implemented, too. For example ElGamal encryption, plain RSA, DSA, etc. ... just stay away of elliptic curve crypto, unless you understand what those actually are.

For usage you might want to learn how to import and use standard crypto libraries, for example, "Cryptlib", "Bouncy Castle", "OpenSSL", etc. E.G. this is a list of libraries.


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