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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.