There is a simple way. Instead of checking if a password looks like a username, you can first translate the username into this sort of "code" and then check if they look the same. Something along the lines of
my %codes = ( l => 1, L => 1, i => 1, I => 1, z => 2, Z => 2, e => 3, E => 3, h => 4, H => 4, s => 5, S => 5, G => 6, g => 9, t => 7, T => 7, b => 8, B => 8, o => 0, O => 0 ); my $user = 'pileofdung'; my $translated; for (split //, $user) { $translated .= (defined $codes{$_}) ? $codes{$_} : $_; } print $translated,$/; # p1130fdun9 my $password = 'p113.0f.dun9%'; my $match =0; for (split //, $translated) { $match++ if $password =~ /$_/ } print "they match\n" if $match >= length($password) -2; # you can choose how lax you want to be by # setting an appropriate number of characters that # you want to be different between username and password # in this case if all but 2 characters are the same, it # is a bad password
Of course, you can use any other comparing methods, but just to give you some ideas to play with.
In reply to Re: Re: Re: Minimal password checking: a summary
by dbwiz
in thread Minimal password checking: a summary
by bronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |