in reply to Keys beside keys on keyboards

You could create a static table of "neighbors" for each allowable password character. (I interpreted "sequential character" to mean any character that touches the current char in any direction):
$neighbors = { a => { q => 1, w => 1, s => 1, z => 1, }, s => { a => 1, w => 1, e => 1, d => 1, x => 1, z => 1, }, etc. }

This hash would be specific to the type of keyboard being used.

You could then traverse, character-by-character, through the password to see if three successive finds occur in the neighbors hash for each letter traversed.

#!/usr/bin/perl use strict; use warnings; my $neighbors = { a => { q => 1, w => 1, s => 1, z => 1, }, s => { a => 1, w => 1, e => 1, d => 1, x => 1, z => 1, }, }; my $password = "asasas"; my $counter = 1; my $lastchar = ""; for my $char (split(//, $password)) { print $char, "\n"; $counter++ if $neighbors->{$lastchar}->{$char}; $lastchar = $char; last if $counter == 3; } if ($counter == 3) { print "Invalid password"; # make them enter a new password... }
Where do you want *them* to go today?

Replies are listed 'Best First'.
Re^2: Keys beside keys on keyboards
by thezip (Vicar) on Nov 07, 2006 at 02:22 UTC

    Update

    I realized on my drive home tonight that I neglected to reset the counter to 1 if it didn't find a match.

    Where do you want *them* to go today?