So I have a password file where users passwords are stored as the MD5 hash of "changeme"..(4cb9c8a8048fd02294477fcb1a41191a)... My script, which asks for the username and password, accepts the password as plain text but I have no idea how to calculate the MD5 hash to compare it to the password file. It seems like it's too complicated to try to write an algorithm for so does anyone know of any ideas? Thanks!

# CSC 310 Project # 3 #opening passwd file open (PSWD, '<', 'passwd.txt'); #getting username and password #converting username to lowercase if anything is entered in CAPS print "Please enter your username: "; chomp($userN = <STDIN>); $username = lc($userN); print "Please enter your password: "; #hiding password system ("stty -echo"); chomp($passwd = <STDIN>); $matchCount = 1; #reading passwd.txt and assigning values while ($lines = <PSWD>){ ($user,$pswd,$userID,$groupID,$info,$home,$shell) = split ':', $li +nes; #checking username entered vs that in the passwd file if ($username eq $user){ print "\nChecking username... MATCH\n"; #keeps track if username matches or not $matchCount += 1; #checking password entered vs that in the passwd file if ($passwd eq $pswd){ print "Checking password... MATCH\n\n"; $matchCount -= 2; } else{ print "Password does not match!\n"; } last; } } # if matchcount did not change, username did not match killing the pro +gram if ($matchCount != 0){ die ("\nEither the username or password did not match.\n"); } ......

Right now, the script checks the plain text of the file (I changed the passwords stored in the password file) and works great, but the MD5 hash is going to throw me off. Any help is appreciated.


In reply to [SOLVED]- FOUND OTHER DOCUMENTATION Encrypting a password to MD5 by jaffinito43

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.