It always confused me that people would create a random salt for a
plaintext password they were about to encrypt, and somehow they
were able to compare an entered password with the encrypted one and
compare for similarity.
As you will see from this script, what happens is that whatever you
choose for a 2 character "salt" is always the same as the first two
characters of the encrypted password.
Therefore, all you have to do is take the plaintext password and use
the _encrypted password_ as the salt, to recreate the entire encrypted
password as long as the plaintext password is the same as the one that
was originally entered.
my $password = 'password';
my $encrypted_password = crypt $password, 'AB';
printf "password: %s encrypted_password: %s\n",
$password, $encrypted_password;
printf "
crypt(password,AB): %s
encrypted_password: %s
crypt(password,BC): %s
crypt(password,encrypted_password): %s
\n",
crypt($password,'AB'),
$encrypted_password,
crypt($password,'BC'),
crypt($password,$encrypted_password);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.