class Hashcheck::Check

Attributes

hash[RW]
hash_type[RW]
name[RW]
salt[RW]
value[RW]

Public Class Methods

new(value,salt="") click to toggle source
# File lib/hashcheck/check.rb, line 5
def initialize(value,salt="")
    @value = value
    @hash_type = get_hash_type
    @hash = get_hash
    @salt = get_salt
    @name = search
end

Private Instance Methods

get_hash() click to toggle source
# File lib/hashcheck/check.rb, line 45
def get_hash()
    case hash_type
    when "devise"
        value[29..59]
    when "linux"
        value.split("$")[3]
    when "mysql"
        value.gsub("*","")
    when "postgres"
        value.gsub("md5","")
    when "plain"
        value
    end
end
get_hash_type() click to toggle source
# File lib/hashcheck/check.rb, line 15
def get_hash_type
    if value.start_with?("$2a") && value.length == 60
        "devise"     
    elsif value.start_with?( '$1', '$2a', '$2',"$5","$6")
        "linux"
    elsif value.start_with?( "*")
        "mysql"
    elsif value.start_with?("md5")
        "postgres"
    else
        "plain"
    end
    
end
get_salt() click to toggle source
# File lib/hashcheck/check.rb, line 30
def get_salt()
    case hash_type
    when "linux"
        value.split("$")[2]
    when "devise"
        self.value[0..28]
    when "mysql"
        ""
    when "postgres"
        ""
    when "plain"
        ""
    end
end