Method: Spider::DataTypes::Password#map

Defined in:
lib/spiderfw/model/datatypes/password.rb

#map(mapper_type) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/spiderfw/model/datatypes/password.rb', line 24

def map(mapper_type)
    return self.to_s if attributes[:hashed]
    salt = attributes[:salt] || Spider.conf.get('password.salt')
    # TODO: better salts
    salt ||= (0..10).inject('') { |r, i| r << rand(89) + 37 }
    hash_type = attributes[:hash] || Spider.conf.get('password.hash')
    return "#{hash_type}$#{salt}$#{self.class.do_hash(hash_type, self.to_s, salt)}"
end