DISQUS

DISQUS Hello! Life is grand is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

Random Ruby Password Magic

Started by paulmwatson · 10 months ago

I have never been a big language geek. My CV lists a raft of them; C#, JavaScript, Ruby, VBScript and even COBOL. But I know many coders (like Kenny, Brian or David) who have a much deeper understanding than I do. On a daily basis Brian shows me twists and turns of C# that [...% ... Continue reading »

4 comments

  • I thought I’d mention that there are two fundamental problems with using a general purpose random number generator (RNG) – regardless of language or platform. The first is scale. If you’re relying on an even distribution in a server context with concurrent users then you’re out of luck with the .NET Framework’s Random class and most other general purpose implementations. This also applies to other applications that rely heavily on random numbers for statistics or game play for example. The second issue is security. Any use of an RNG is a prime target for attack as they can easily be foiled to produce the same number. This is a problem when random numbers are used for passwords, establishing session keys, etc. What you need is a cryptographic RNG. For managed code you can rely on the RNGCryptoServiceProvider class. Does Ruby provide something comparable?
  • IMO I prefer 8.times over 1.upto(8).
  • Nice improvement, thanks Farrel.
  • password = (1..8).collect { |i| schars[rand(schars.length), 1]}

Add New Comment

Returning? Login