Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Random password widgets may not be random' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Random password widgets may not be random
Authored by: SnakeO on Sep 03, '05 02:34:18AM

[code]
jot -r -c 160 a z | rs -g 0 8
[/code]



[ Reply to This | # ]
10.4: Random password widgets may not be random
Authored by: guybrush on Sep 03, '05 06:55:23AM

cool, never heard about those 2 commands, neat! :)



[ Reply to This | # ]
Going one better
Authored by: Lectrick on Sep 06, '05 12:22:56AM
Since you stole that right from the man page for jot ;) , I figured I'd use my Unix-fu to whip it into something slightly better. The example given only generates passwords with all-lowercase letters. But then there's:

jot -r -c 200 33 122 | sed 's/[^[:alnum:]]//' | rs -g 0 8

This will spit out 8 character passwords consisting of mixed case and numbers. Because the sed portion acts like a filter, the output length will vary, but you can choose how many characters per word by changing the 8 at the end, and you can choose how many random characters you want "jot" to try to generate by changing the 200. If you want to allow a few extra characters like asterisk, !, ? etc, you can try adding them like this:

jot -r -c 200 33 122 | sed 's/[^[:alnum:]*+@\?!\._]//' | rs -g 0 8

In this case I'm allowing not only alphanumerics but asterisk, plus, at-sign, question mark, exclamation point, period, and underscore. (Notice that the question mark and period have to be escaped with a backslash before them as these are normally "special" characters in regular expressions, so consider those one unit in case you delete them here.)

Fun stuff ;)

---
In /dev/null, no one can hear you scream

[ Reply to This | # ]

Going one better... backslashes are omitted
Authored by: Lectrick on Sep 06, '05 12:25:05AM

Please note that even though I surrounded the above code with the relevant Code tags, it STILL omitted the backslashes!!! (grrrr)

Just please assume there are backslashes. I'm going to try again below without the code tags:

jot -r -c 200 33 122 | sed 's/[^[:alnum:]*+@\?!\._]//' | rs -g 0 8

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
nevermind. backslashes NOT NEEDED!
Authored by: Lectrick on Sep 06, '05 12:52:59AM

Sorry for the repeated followups.

It appears that, unlike "normally" when you have to escape periods and question marks, in this case you don't, and if you do put backslashes there then they will just be treated as a regular allowed character and you will get passwords with backslashes in them (usually a no-no).

So to reiterate, this is perfectly fine:

jot -r -c 200 33 122 | sed 's/[^[:alnum:]*+@?!._]//' | rs -g 0 8

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
That was the bash version. tcsh here
Authored by: Lectrick on Sep 06, '05 08:18:48AM

For some reason, in the tcsh shell you have to escape the exclamation point by putting a backslash before it... so do that (or omit the !). FYI

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]