- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
First to say First.
Admin
Admin
Leper! Outcast! Unclean!
However, as a WTF this one really isn't so awful. GeneratePassword uses decent randomness, and stripping out non-alphas is OK for a URL.
Admin
I see the WTF, they should have used a regexp.
Admin
Just make a char[] and fill it with random numbers between 'a' and 'z', return it with the string constructor.
Admin
Admin
What have you done with 98?
Admin
Random? Check.
Clean? Oh ...
Nothing to do with Shanghai girls, then ...
Admin
Is the WTF that he returns an "uncleanRandomString" instead of a clean one?
Admin
Why not just use /dev/random?
That's what it's there for.
Admin
When selecting trim, randomness is the most desired trait. Cleanliness is the second.
Admin
The idea is not so horrible. Chances are low, but this definitely increased the possibility of generating two identical random strings.
But you weren't looking for ASCII conversion, you were looking for HttpServerUtility.UrlEncode(str), isn't it?
Admin
Admin
protected String getRanString() { // Random string generated by a fair pick of scrabble letters for a bag return "Brillant"; }
Admin
What?!? Don't you remember the song:
Admin
Admin
public static string GeneratePassword (int length, int numberOfNonAlphanumericCharacters)
protected String getRanString() { return GeneratePassword(10,0); }
The remaining code is useless because the 2nd argument asks for zero punctuation characters.
Admin
Noone's posted "Frist" as parsed by that encoder?
I am disappoint.
Admin
Admin
Admin
I can see 'i' and 'e', but then I'm irrational
Admin
Wondering how the creator of this mess decided on which characters to substitute for the "bad" chars. "a" appears twice, there are some letters and some numbers. It would seem that the easiest options are to either replace everything with the same letter, or replace !->a, @->b, #->c, etc.
Why do I have the sneaking suspicion that he ran GeneratePassword and hand-selected the alphanumerics to use as the substitute in order to be "more randomer"?
Admin
You mean he meant that the original creator of that code probably didn't know that?
Well, that was funny.
Admin
Admin
Admin
Admin
obligatory xkcd:
http://xkcd.com/221/
Admin
Admin
from http://msdn.microsoft.com/en-us/library/system.web.security.membership.generatepassword.aspx
public static string GeneratePassword( int length, int numberOfNonAlphanumericCharacters )
...even though it's specified in the docs that it's the minimum number of the alpha chars (not the actual) it's totally lame that the second parameter is called 'numberOfNonAlphanumericCharacters' and not 'minimumNumberOfNonAlphanumericCharacters' (or some shorter equivalent)
Admin
Guids, man. Pork of the future.
Admin
"System.Web.Security.Membership.GeneratePassword"? Ugh. You think they could cram a few more levels of hierarchical namespacing into that if they tried? Just in case 5 isn't ugly enough for someone out there?
Admin
ACK and you say receive: System.Web.Application.Security.Membership.User.Account.Password.GeneratePassword
Admin
Admin
Com.Innotech.corporation.We.Build.The.Future.TM.System.Web.Application.Security.Membership.User.Account.Password.GeneratePassword
Admin
You need to use a different keyboard layout. qwerty or azerty won't work. Try dvorak.
Admin
Code Challenge: The shortest legible password generator that considers the following:
Bonus points:
Admin
#!/usr/bin/perl sub GenPW{print "Go ask your mom\n";} 1;
Admin
First thing that came to my mind as well ...
Admin
What? Didn't he know you should do it all in one line?
Admin
Admin
There are plenty of numbers between 'a' and 'z':
perl -e '$X="a";while ($X le "z"){print $X++;}' abcdefghijklmnopqrstuvwxyz
Admin
Thomas Covenant. Classy :).
Admin
Ran string is string that constantly runs through memory invalidating its pointer.
Admin
Admin
At least the implementation is encapsulated in its own method and can easily be refactored. That's of far more value than the WTFish implementation.
Admin
I see i, v, x, l, c, d, and m.
You're not limiting yourself to those new-fangled Hindu-Arabic numerals, are you? They're just a passing fad.
Admin
Very witty, sir.
But I just have to be pedantic and point out that "i" is not irrational: it is imaginary. "Not rational" is not the same as "irrational".
Admin
Admin