From: Alexandru Popescu Date: 2006-07-16T09:30:47+09:00 Subject: Re: salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp To my understanding: creates Array.new(6){rand(256).chr} => array of 6 random chars array.join => string of 6 chars [array.join] => array with 1 string of length 6 newarray.pack("m") => encode base64 and the last chomp assures that the last generated char is not a newline. hth (even if I am not completely sure about it, and I would like to hear from more experienced guys). ./alex -- .w( the_mindstorm )p. On 7/16/06, Alexandre Hudelot wrote: > This is a line taken from the "authentification" recipe in the 'Rails > Recipes' book. > I can see that it generates a string of random characters but I am > unsure of all that's going on here. > > The strings that are generated have 8 characters, how come when the > array is initialized with the arg '6' ? > > What exactly is .join doing here? > > What does .pack("m") do? > > And why the .chomp? I thought that was a func to remove newline > characters. > > Thanks in advance for the help. > > -Alex > > -- > Posted via http://www.ruby-forum.com/. > >