my $cleartext = whatever(); my $salt = '$1$'; $salt .= ('A' .. 'Z', 'a'..'z', '0'..'9', '.', '/')[rand 64] for 1..8; my $crypted = crypt $cleartext, $salt; # verifying password my $cleartext = whatever(); my $crypted = getfromdb(); if (crypt($cleartext, $crypted) eq $crypted) { # correct password } else { # incorrect... }