Guest User

Untitled

a guest
Jan 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. [root@web:accountapi/lib]# cat apicommon.rb (04-05 18:13)
  2. require 'yaml'
  3.  
  4. class Apicommon
  5.  
  6. def self.password(size = 9)
  7. chars = (('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0)
  8. password = (1..size).collect{|a| chars[rand(chars.size)] }.join
  9. return password
  10. end
  11.  
  12. def self.salt
  13. chars = ('a'..'z').to_a
  14. salt = (1..2).collect{|a| chars[rand(chars.size)]}.join
  15. return salt
  16. end
  17.  
  18. def self.loadconfig
  19. conffile = "config/accountapi.yml"
  20.  
  21. if File::exists?(conffile)
  22. conffd = File.open(conffile)
  23. conf = YAML.load(conffd)
  24. conffd.close
  25. else
  26. puts "No configuration file found, exiting..."
  27. exit
  28. end
  29.  
  30. $minuid=conf['minuid']
  31. $adminuser=conf['adminuser']
  32. $adminpassword=conf['adminpassword']
  33. $minpwdlength=conf['minpwdlength']
  34. $minuserlength=conf['minuserlength']
  35. end
  36.  
  37. end
Add Comment
Please, Sign In to add comment