Phonetically Memorable Password Generation Algorithms

后端 未结 17 2423
生来不讨喜
生来不讨喜 2021-01-30 00:05

Background

While at the Gym the other day, I was working with my combination lock, and realized something that would be useful to me as a programmer. To wit, my combin

17条回答
  •  萌比男神i
    2021-01-30 00:44

    Here's part 2 of your idea prototyped in a shell script. It takes 4, 5 and 6 letter words (roughly 50,000) from the Unix dictionary file on your computer, and concatenate those words on the first character.

    #! /bin/bash
    
    RANDOM=$$
    WORDSFILE=./simple-words
    DICTFILE=/usr/share/dict/words
    grep -ve '[^a-z]' ${DICTFILE} | grep -Ee '^.{4,6}$' > ${WORDSFILE}
    N_WORDS=$(wc -l < ${WORDSFILE})
    for i in $(seq 1 20); do
        password=""
        while [ ! "${#password}" -ge 8 ] || grep -qe"^${password}$" ${DICTFILE}; do
            while [ -z "${password}" ]; do
                password="$(sed -ne "$(( (150 * $RANDOM) % $N_WORDS + 1))p" ${WORDSFILE})"
                builtfrom="${password}"
            done
            word="$(sort -R ${WORDSFILE} | grep -m 1 -e "^..*${password:0:1}")"
            builtfrom="${word} ${builtfrom}"
            password="${word%${password:0:1}*}${password}"
        done
        echo "${password} (${builtfrom})"
    done
    

    Like most password generators, I cheat by outputting them in sets of twenties. This is often defended in terms of "security" (someone looking over your shoulder), but really its just a hack to let the user just pick the friendliest password.

    I found the 4-to-6 letter words from the dictionary file still containing obscure words.

    A better source for words would be a written document. I copied all the words on this page and pasted them into a text document, and then ran the following set of commands to get the actual english words.

    perl -pe 's/[^a-z]+/\n/gi' ./624425.txt | tr A-Z a-z | sort -u > ./words
    ispell -l ./words | grep -Fvf - ./words > ./simple-words
    

    Then I used these 500 or so very simple words from this page to generate the following passwords with the shell script -- the script parenthetically shows the words that make up a password.

    backgroundied (background died)
    soundecrazy (sounding decided crazy)
    aboupper (about upper)
    commusers (community users)
    reprogrammer (replacing programmer)
    alliterafter (alliteration after)
    actualetter (actual letter)
    statisticrhythm (statistical crazy rhythm)
    othereplacing (other replacing)
    enjumbling (enjoying jumbling)
    feedbacombination (feedback combination)
    rinstead (right instead)
    unbelievabut (unbelievably but)
    createdogso (created dogs so)
    apphours (applications phrase hours)
    chainsoftwas (chains software was)
    compupper (computer upper)
    withomepage (without homepage)
    welcomputer (welcome computer)
    choosome (choose some)
    

    Some of the results in there are winners.

    The prototype shows it can probably be done, but the intelligence you require about alliteration or syllable information requires a better data source than just words. You'd need pronunciation information. Also, I've shown you probably want a database of good simple words to choose from, and not all words, to better satisfy your memorable-password requirement.

    Generating a single password the first time and every time -- something you need for the Web -- will take both a better data source and more sophistication. Using a better programming language than Bash with text files and using a database could get this to work instantaneously. Using a database system you could use the SOUNDEX algorithm, or some such.

    Neat idea. Good luck.

提交回复
热议问题