Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Crypt::CBC and verifying passwords

by Anonymous Monk
on May 19, 2004 at 21:07 UTC ( [id://354766]=note: print w/replies, xml ) Need Help??


in reply to Crypt::CBC and verifying passwords

'iv' => 'vectory!',
Avoid using a fixed IV if at all possible. If two passwords have the same initial 8 characters, then their encrypted forms will also have the same first 8 characters. Random IVs avoid that information leak. See Practical Cryptography for more information.

Some other posters on this thread seem to think that the random IV is a "problem" because it makes the encrypted form different every time you encrypt it. This appears to be because they don't understand the difference between an encryption function (like DES or Blowfish) and a one-way hash function (like MD5 or SHA1). The former can be decrypted so you can get the original back and compare originals. The latter can't be reversed, so you must compare the mangled versions.

'key' => 'stringie',
You're never going to be able to change the encryption key without breaking everything. That's bad.
'padding' => 'space',
In general, space padding is a bad idea (you can't recover the exact original message if it had trailing spaces), but for passwords it might be ok.
my $dbpwmd5 = $cipher->encrypt_hex($dbpw);
If it's not MD5, don't call it MD5.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://354766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found