in reply to how to crypt and decrypt password from 4 to 15 characters in length

Further to ikegami's answer, not only does Crypt::CBC make things easier for you, it is also a lot more secure than manually encrypting the data in 8-byte chunks, because it XOR's each block with the preceding block, thus making it harder to spot data patterns (this doesn't matter much for small pieces of data like passwords, but is good to keep in mind in general).

Also, if you want any kind of real security:

  1. Don't use passwords with less than eight characters
  2. Don't use DES, it has known weaknesses and should no longer be used for any serious encryption. Crypt::CBC also works with lots of stronger ciphers, such as Crypt::IDEA, Crypt::Blowfish or Crypt::Rjindael (just substitute -cipher => 'DES' in ikegami's code with -cipher => 'Blowfish' and make sure you have the relevant module installed).Update: I see ikegami has added an update with the same recommendation while I was typing mine. I'll type quicker next time :-)

There are ten types of people: those that understand binary and those that don't.