How to read the dictionnary ?

G

Globule

Hi,

I would like to random search the dictionnary for word from 6 to 10 letters long.

My idea is to suggest passwords to users...

Does anybody have an Idea ?
 
S

Scott M.

Do you have "the dictionary" in electronic queryable form somewhere? If so,
it would just be a simple matter of creating a subset of the data that
conforms to your 6 to 10 characters long rule, then generating a random
number between 1 and the number of words that are in the subset and
extracting that particular word.
 
J

Jay Freedman

Word's built-in dictionary is not searchable, mainly because it
doesn't contain whole words in readable form. It contains word roots,
prefixes, suffixes, irregular forms, and coded rules for constructing
matches, finding synonyms, and so forth.

What you can do is put a random "word" into a document, run the
spellchecker on it, and see whether it suggests any corrections. You
can do this in a loop, continuing until you get a suggestion. The code
for this is below.

The real problem is that for security, passwords should never be
ordinary words taken from a dictionary. Such passwords are vulnerable
to a "dictionary attack" -- a hacker merely tries thousands of words
from his own dictionary, and eventually finds the one you used. If
random strings of characters are too hard to remember, you should
start with a word you can remember and replace some of its characters
with numbers, transpose some characters, and use odd combinations of
upper and lower case.

For instructional purposes, here's sample code for the dictionary
"search":

Sub SuggestWord()
Dim myRg As Range
Dim seed As String, pwd As String
Dim idx As Integer
Dim bDone As Boolean
Const CharList = "abcdefghijklmnopqrstuvwxyz"
Randomize

Set myRg = ActiveDocument.Range
With myRg
' separate seed from last word in doc
.Collapse wdCollapseEnd
.Text = " "
.Collapse wdCollapseEnd

bDone = False
Do While Not bDone
' create a random 8-char seed
seed = ""
For idx = 1 To 8
seed = seed & Mid(CharList, 26 * Rnd + 1, 1)
Next idx
' insert it at end of doc
.Text = seed

' see whether spellchecker suggests a "correction"
If .Words(1).GetSpellingSuggestions.Count <> 0 Then
pwd = .Words(1).GetSpellingSuggestions.Item(1).Name
' check whether length is 6 to 10 chars
If (5 < Len(pwd)) And (Len(pwd) < 11) Then
MsgBox pwd
bDone = True
End If
End If
Loop

' clean up -- delete myRg and preceding space
.Delete
ActiveDocument.Characters.Last.Previous.Delete
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top