I'm looking for a library for encrypting and decrypting a string which provides the following properties:
- Using an encryption mode block or stream, besides that I'm indifferent towards the algorithm.
- Should support a key with small length, small enough to enable known text cipher attack.
- Preferably should be able to take care of low level cryptography issues such as padding decisions.
For example:
string Encrypt(int key, string messageToBeEncrypted) // returns cipher
string Decrypt(int key, string messageToBeDecrypted) // returns message
mcryptis very easy to use. Doesn't have padding, but it's trivial to write a PKCS padder. - Kerrek SBmcryptand so on are all out, because they only supply unacceptably strong block ciphers? Or would it be acceptable to use a strong cipher, but with an application-specific restriction that the key will not exceed a certain length, thus ensuring that it is weak when you use it, even though it isn't weak when used properly? I suppose DES has only 56 bit keys, and is inmcrypt. It's considered weak, its keys are 56 bits, which is brute-force crackable but not trivially so. - Steve Jessop