2010/8/24 Hd Pwnz0r <human.dictionary / rocketmail.com>: > I'm making a secure password generator, where the user inputs a word and > it translates it to something more secure, so if they entered "book" it > would return "b00k". I just don't know how to say like > > if input contains "S" replace with "$" > > etc. > > Help? Use regular expressions: string = "password" new_string = string.gsub(/[sS]/,'$') ## 'pa$$word' You can chain the calls newer = string.gsub(/[sS]/,'$').gsub(/[oO]/,'0') ## 'pa$$w0rd' or even define a hash with all your transformations using inject to apply them to your string transfo_hash = {/[sS]/ => '$', /[oO]/ => '0', /[aA]/ => '4'} transfo_hash.inject(string) {|sum_string,h| sum_string.gsub(h[0],h[1])} ## p4$$w0rd But I would say as Peter that it is not really more secure than the original string. @Peter: how do you remember the couple login/password that are randomly chosen ? Do you store them somewhere ? Cheers, JJ Fleck PS: see also http://xkcd.com/538/