Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mnemonic Password Generation Algorithm for QWERTY Keyboards

I've a "mnemonic" password generation function that goes something like this:

function Mnemonic($mnemonic)
{
    $result = null;
    $charset = array(str_split('aeiou', 1), str_split('bcdfghjklmnpqrstvwxyz', 1));

    for ($i = 1; $i <= $mnemonic; $i++)
    {
        $result .= $charset[$i % 2][array_rand($charset[$i % 2])];
    }

    return $result;
}

Basically this generates a string with $mnemonic length where every odd character is a consonant and every even character is a vowel. While I understand this reduces the password complexity it's usually much more easier to remember. Now I want to improve it by generating strings that are easy to type.

QWERTY Keyboard Layout

For instance, while a *nix newbie I always prefer RHEL based distributions over Debian ones, the main reason is the ease of typing yum versus the ease of typing apt[-get], just try it for yourself.

How should I implement the logic to generate strings that are easy to type on QWERTY keyboards?

like image 885
Alix Axel Avatar asked Feb 05 '10 17:02

Alix Axel


3 Answers

Carpalx has a lot of research on calculating typing effort, which incorporates:

  • finger travel distance
  • hand, finger and row penalties
  • stroke path

The outcome of their research is the Colemak keyboard layout, which claims to be better than Dvorak.

However, it's written backward from what you want - their goal is to find a better keyboard layout based on input, but you're trying to find easy input based on the keyboard layout.

So - even though you might not be able to use it directly, I thought you might find it interesting (and who knows, if your Perl-fu is strong, you might be able to extract and reverse the algorithm, since it's GPL'd).

like image 71
mskfisher Avatar answered Nov 01 '22 03:11

mskfisher


You could eliminate all characters that are typed with the ring and pinky finger (q,w,x,z,p), then spit the characters that are typed by the left and the right hands and alternate between these letters.

like image 21
superUntitled Avatar answered Nov 01 '22 05:11

superUntitled


You may wanna take a look at the principles used in the Dvorak keyboard,

Those principles applied in a password-generating algorithm would be:

  • Letters should be typed by altering hands.
  • Use easy to type combinations. Take a look at the Dvorak layout and see the common digraphs and the positions of their letters.
  • Use only one letter from the bottom row, or not. Make it random!
  • You can make the ratio 2 to 1 (2 letters typed by the right hand to 1 letter typed by the left hand).
  • Since the ratio is 2 to 1, you're gonna have 2 consecutive letters typed by the same hand so you're gonna have to make sure they are typed from the outside of the keyboard to the inside. This principle is applied to the digraphs.

I know you said it's a QWERTY keyboard but using these principles on a QWERTY keyboard can give you some very good results, like:

ktrd,ogkdo ("typewriter" in dvorak)

kjg;g;akd;k (using only the home row)

pjedoildupsk (just a random password following the principles)

All Dvorak haters, shush it!

I hope this helps.

like image 1
Leo Jweda Avatar answered Nov 01 '22 03:11

Leo Jweda