Module: Digest::Instance

Defined in:
lib/standard/facets/digest/base64digest.rb,
lib/standard/facets/digest/salted_digest.rb

Instance Method Summary collapse

Instance Method Details

#base64digest(str = nil) ⇒ Object

From Ruby 1.9.2 source


12
13
14
# File 'lib/standard/facets/digest/base64digest.rb', line 12

def base64digest(str = nil)
  [str ? digest(str) : digest].pack('m0')
end

#base64digest!Object

From Ruby 1.9.2 source


21
22
23
# File 'lib/standard/facets/digest/base64digest.rb', line 21

def base64digest!
  [digest!].pack('m0')
end

#salted_base64digest(str, salt) ⇒ Object

CREDIT: Guido De Rosa


21
22
23
# File 'lib/standard/facets/digest/salted_digest.rb', line 21

def salted_base64digest(str, salt)
  [salted_digest(str, salt)].pack('m0')
end

#salted_digest(str = '', salt = :auto) ⇒ Object

CREDIT: Guido De Rosa


8
9
10
11
12
13
# File 'lib/standard/facets/digest/salted_digest.rb', line 8

def salted_digest(str='', salt=:auto)
  if salt == :auto
    salt = String.random_binary(digest_length) 
  end
  digest(str + salt) + salt
end

#salted_hexdigest(str, salt) ⇒ Object

CREDIT: Guido De Rosa


16
17
18
# File 'lib/standard/facets/digest/salted_digest.rb', line 16

def salted_hexdigest(str, salt)
  Digest.hexencode(salted_digest(str, salt))
end