I wrote a small test program using Tcl to generate a password dictionary.

Source: Internet
Author: User
Bored, I wrote a small program to generate a password dictionary, as a staged Summary of learning TCL.
You can generate any combination of dictchar characters and set the password length.
Use tclsh8.4 In Debian to pass the test.

#! /Usr/bin/tclsh

#*************************************** *********
# Password dictionary Generator
# Just for learning, by easwy, Mar 31,200 6
#
# Len-the length of password
#
# Return
# None, password group in file $ dictname
#*************************************** *********
Proc gendict {Len }{
# Chars in Password
Set dictchar "abcdefghijklmnopqrstuvwxyz"
# Count of chars
Set charcnt [String Length $ dictchar]
# Last item's index in array
Set last [expr "$ len-1"]
# Dictionary file name
Set dictname "passwd.txt"

# Initial array
For {set I 0} {$ I <$ Len} {incr I }{
Set a ($ I) 0
}

# Open dictionary file
Set dictfile [open "passwd.txt" W]

# Starting...
While {true }{
# Construct new passwd
Set passwd ""
For {set I 0} {$ I <$ Len} {incr I }{
# Append char which index is $ A ($ I) to passwd Str
Set passwd "$ passwd [String index $ dictchar $ A ($ I)]"
}

# Output passwd
Puts $ dictfile $ passwd

# Incr last Char's index
Incr A ($ last)

# Update all indices
For {set I $ last} {$ I> 0} {incr I-1 }{
If {$ A ($ I) >=$ charcnt }{
Set a ($ I) 0
Set ind [expr "$ I-1"]
Incr A ($ IND)
}
}

# Exit
If {$ A (0) >=$ charcnt} {break}
}

Close $ dictfile
}

# Generate passwd string, Len 3
Gendict 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.