|
このページは大阪弁化フィルタによって翻訳生成されたんですわ。 |
Here is a real word password generator that selects words from Robelle's spelling dictionary to use as passwords. Say you want to generate 6-letter passwords. Suprtool's string pattern match can give you a list of 6-letter words sorted in alphabetical order.
Although Suprtool does not have a function that randomly selects from a list of words, it can select words based on these not-so-obvious algorithms:
input maincomm.spdata.robelle
def word,1,24
if word=="??????~"
{pattern match on 6 characters followed by a space}
out word6
xeq
Randomize the list by converting one of the letters to an integer and sorting
on it. This task also reduces the number of words in the list by comparing the
integer representation of two letters.
def i,6,2,int {1st num can range from 1..n-1}
def j,5,2,int {1st num can range from 1..n-1}
def k,3,2,int {1st num can be 1..n-1, but 2..n-2 is better}
in word6
if i>j {ij}
sort k
ext word
purge word6a
out word6a
xeq
Make a selection from the file--in this case every 43rd record to a maximum
of 50 records.
in word6a(#43)
numrecs 50
purge passwd
out passwd
xeq
Because these passwords come from a list of real words, you should review the
final list to eliminate easy-to-guess words.
In the section above, we showed you a Suprtool task that extracts a random list of n-letter words to use as passwords. Of course, some real-world situations require slightly harder-to-guess passwords that are also only slightly more difficult to remember. This time we will use a Suprtool task to simulate the telephone-book algorithm for generating passwords: open the phone book to a random page, point at a name, and use the first four letters of the name plus the last four digits of the phone number as the password (e.g., smit3681).
input maincomm.spdata.robelle
define word,1,24
if word == "??????@" {n = number of ?'s, 5..16 }
:purge words
output words
xeq
input words
define word4,1,4 {4 letters}
define i,2,2,int {start pos can range from 1..n-1}
define j,4,2,int {start pos can range from 1..n-1}
define k,6,2,int {start pos can range from 5..n-1}
define digits,1,4,display {4 digits}
sort k
extract word4
extract digits = (i * j) mod 10000
:purge passwds
output passwds
xeq
The example shows fields i, j, and k starting at byte positions 2, 4, and
6, but you can choose any starting positions you like within the record.
:setvar size finfo('passwds','eof') - 1
:setvar finger ((!hpconnsecs + !hpsusan) mod size) + 1
:echo input passwds(#!finger) >usefile
use usefile
numrecs 2
:purge passwd
output passwd
xeq
:print passwd;start=2