r1 - 13 Mar 2008 - 21:40:58 - CharinyaKlakhangYou are here: SETEC Wiki >  Knowledge Web  > WebTechnologyCategory > RubyOnRails > RandomStringRubyOnRails

Random String Ruby On Rails

   def random_string(size = 4)
      c = %w(B b c d f G h j k l m N p qu r s T v w x z ch cr fr nD ng nk nt ph pr rd sh SL st th it)
      v = %w(a E i o u Y)
      f, r = true, ''
      (size * 2).times do
        r << (f ? c[rand * c.size] : v[rand * v.size])
        f = !f
      end
      r
      end

Ref. http://www.geekpedia.com/code89_Pronouncable-Random-Password-Generator.html

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by SETEC Wiki
Copyright ©2012 by National Electronics and Computer Technology Center, NECTEC.
Ideas, requests, problems regarding SETEC Wiki? Send feedback