Skip to content

Instantly share code, notes, and snippets.

@dlapiduz
Created August 4, 2009 15:00
Show Gist options
  • Save dlapiduz/161291 to your computer and use it in GitHub Desktop.
Save dlapiduz/161291 to your computer and use it in GitHub Desktop.
def set_rnd_pass
digitpct = 0.4
letterset = ('A'..'Z').to_a - ['I', 'O']
#begin
passwd = ''
8.times do
if rand < digitpct
passwd << rand(10).to_s
else
passwd << letterset[rand(letterset.length)]
end
end
self.password = passwd
encrypt_password
self.save_without_validation
passwd
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment