Class: Digest::Class

Inherits:
Object
  • Object
show all
Defined in:
lib/1.8/openssl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.digest(data, name) ⇒ Object



27
28
29
30
31
# File 'lib/1.8/openssl.rb', line 27

def self.digest(data, name)
  digester = const_get(name).new
  digester.update(data)
  digester.finish
end

.hexdigest(name, data) ⇒ Object



23
24
25
# File 'lib/1.8/openssl.rb', line 23

def self.hexdigest(name, data)
  digest(name, data).unpack('H*')[0]
end

Instance Method Details

#==(oth) ⇒ Object



41
42
43
# File 'lib/1.8/openssl.rb', line 41

def ==(oth)
  digest == oth.digest
end

#digestObject



37
38
39
# File 'lib/1.8/openssl.rb', line 37

def digest
  dup.finish
end

#hexdigestObject



33
34
35
# File 'lib/1.8/openssl.rb', line 33

def hexdigest
  digest.unpack('H*')[0]
end

#lengthObject



53
54
55
# File 'lib/1.8/openssl.rb', line 53

def length
  digest_length
end

#sizeObject



49
50
51
# File 'lib/1.8/openssl.rb', line 49

def size
  digest_length
end

#to_sObject



45
46
47
# File 'lib/1.8/openssl.rb', line 45

def to_s
  hexdigest
end