Why u need to be careful when using /dict/words...
GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why u need to be careful when using /dict/words...
A big warning:
**always follow Murphy's laws to their full extent!**
I was working on a php application which uses log-ins.
The client wanted some friendly way to have users remember their password, maybe something with a combination of real words, -fine- said I.
As a prototype I prepared a simple script which used the /dict/words file, nothing over the top, the script would output a combination of two hyphenated word, so that the guy could play with it and tell me if he liked it.
Would you ever believe that the first two words the script produced where sh**-head?
Need I to say that the guy was NOT pleased at all?
Anybody fancies calculating the chances of that happening?
Well, wc says mine contains 45427 words. So, any two-word combination should be 1-in-(45427-squared), or 1-in-2-billion-ish. It's the same odds for "soda-pop" as it is for "dog-sh**".
Originally posted by ranger_nemo Well, wc says mine contains 45427 words. So, any two-word combination should be 1-in-(45427-squared), or 1-in-2-billion-ish.
Apologies for this, my math is a bit rusty, you used something like:
Dn,k=n.(n-1)....(n-k+1) where k=2 and n=45427 to calculate it? Dunno what is called in english.
If you are picking completely at random, it is possible to pick the same word twice, and thereby the number of combos is N-squared. I didn't bother to put it on the calculator, but it should be about 2.064-billion-ish.
If you are removing the first word picked, then you would need to subtract one from N for the second word, and thereby the number of combos would be N(N-1), or NN-N, or 2.064-billion-ish minus 45427, which is still 2.064-billion-ish. Remove the red combos above.
Originally posted by ranger_nemo No, I just used a simple squaring... If there were only five words [ A,B,C,D,E ], then all possible combinations would be...
If you are picking completely at random, it is possible to pick the same word twice, and thereby the number of combos is N-squared. I didn't bother to put it on the calculator, but it should be about 2.064-billion-ish.
If you are removing the first word picked, then you would need to subtract one from N for the second word, and thereby the number of combos would be N(N-1), or NN-N, or 2.064-billion-ish minus 45427, which is still 2.064-billion-ish. Remove the red combos above.
Yes, the combination did not include repetition, the idea was to have unique values, althought the positioning of the words would have been random, that way A-B != B-A although A and B are the same words.
The D(n,k) would be D(n,k)=45427*(45427-1) I think, which would be fairly close to the square of the number.
Originally posted by SciYro LOL, i cant seem to stop laughing at this,... just you luck eh?
/me is reminded of a Dilbert comic strip
I have removed all the "naughty"words from the word list so that it should give less "entertaining" results. Was thinking of setting up a cron to run the program and save the result to db, and then check to see what comes out of it. You know the thing about monkeys, typewriters and eternity
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.