Check password : Compare « String « Perl






Check password

    

$encrypted = "AB/uOsC7P93EI";

$salt = substr($encrypted, 0, 2);

print "Guess the word: ";

while(<>) {

    chomp;
    if ($encrypted eq (crypt $_, $salt)) {
        print "You got it!";
        exit;
    } else {
        print "Nope.\n";
        print "Guess the word: ";
    }
}

   
    
    
    
  








Related examples in the same category

1.Compare two words with cmp
2.Comparing Strings
3.String comperison operator: cmp
4.String comperison operator: equal
5.String comperison operator: gt (greater than)
6.String comperison operator: lt (less than)
7.The correct use of three of the operators: eq, it, and gt.
8.A very simple password checker.