| Class | String |
| In: |
lib/utility/utility.rb
|
| Parent: | Object |
Encrypts a password
# File lib/utility/utility.rb, line 44 def encrypt alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./' salt = "#{alphabet[rand(64)].chr}#{alphabet[rand(64)].chr}" self.crypt(salt) end
Takes a string containing a list of keywords, like ‘hello world’, and checks if ‘str’ is a prefix of any of those words? "hell" would be true
# File lib/utility/utility.rb, line 26 def is_match? str return false if self.empty? || str.nil? || str.empty? lst = self.split(' ') lst.each do |s| return true if str.downcase == s.slice(0...str.size).downcase end false end
Compares the password with the string
# File lib/utility/utility.rb, line 38 def is_passwd?(pwd) pwd == self.crypt(pwd) end
Checks if ‘str’ is a prefix of this string
# File lib/utility/utility.rb, line 18 def is_prefix? str return false if self.empty? || str.nil? || str.empty? self.downcase == str.slice(0...self.size).downcase end