You can find many codes to encrypt a string on the Internet.
There is just one small problems - all this “algorithms” are rubbish!
However, don’t worry! There are great Delphi components (I use them as classes) - DCPCrypt.
This components package have implemented many strong cipher and hash algorithms.
So, I guess that you think “Great components? Many algorithms? No, thank you, I don’t have 500$ to spend.”
I will surprise you - these components are developed on MIT License - you can do everything with them for free!

What’s inside?

Cipher algorithms:

  • Blowfish
  • Cast 128, Cast 256
  • DES, 3DES
  • Ice, Thin Ice, Ice2
  • IDEA
  • Mars
  • GOST
  • Misty1
  • RC2, RC4, RC5, RC6
  • Rijndael
  • Serpent
  • Tea
  • Twofish

Hash algorithms:

  • Haval
  • MD4
  • RipeMD-128
  • RipeMD-160
  • SHA-1
  • SHA-256, SHA-384, SHA-512
  • Tiger

Strange names? Don’t worry, I’ll describe all this algorithms on the next pages.

Cipher? Hash?

Cipher is an algorithm that encrypts some data that can be decrypted back to the plain text.
Hash is an algorithm that calculates a checksum of some data that can’t be decrypted back to the plain text - it’s often used for storing passwords.

String Encryption Unit

It’s a bit hard to cipher a string with DCPcrypt, because it’s universal (you can crypt buffer, stream etc.).
Because of that, I’ve written few functions that make encryption as easy as it’s possible.
It has two main functions:

Code (delphi)
  1. function EncryptStr(CipherClass : TDCPCipherClass; HashClass : TDCPHashClass; Str, Key : String) : String;
  2. function DecryptStr(CipherClass : TDCPCipherClass; HashClass : TDCPHashClass; Str, Key : String) : String;

So, all you have to do is to type cipher and hash class, text that you want to (de)crypt and key.
Cipher classes:

  • TDCP_blowfish
  • TDCP_cast128
  • TDCP_cast256
  • TDCP_des
  • TDCP_3des
  • TDCP_gost
  • TDCP_mars
  • TDCP_ice
  • TDCP_idea
  • TDCP_misty1
  • TDCP_rc2
  • TDCP_rc4
  • TDCP_rc5
  • TDCP_rc6
  • TDCP_rijndael
  • TDCP_serpent
  • TDCP_tea
  • TDCP_twofish

Hash classes:

  • TDCP_haval
  • TDCP_md4
  • TDCP_md5
  • TDCP_ripemd128
  • TDCP_ripemd160
  • TDCP_sha1
  • TDCP_sha256
  • TDCP_sha512
  • TDCP_tiger