Class: Puppet::SSL::Digest

Inherits:
Object show all
Defined in:
lib/puppet/ssl/digest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(algorithm, content) ⇒ Digest

Returns a new instance of Digest.



4
5
6
7
# File 'lib/puppet/ssl/digest.rb', line 4

def initialize(algorithm, content)
  algorithm ||= 'SHA256'
  @digest = OpenSSL::Digest.new(algorithm, content)
end

Instance Attribute Details

#digestObject (readonly)

Returns the value of attribute digest.



2
3
4
# File 'lib/puppet/ssl/digest.rb', line 2

def digest
  @digest
end

Instance Method Details

#nameObject



17
18
19
# File 'lib/puppet/ssl/digest.rb', line 17

def name
  @digest.name.upcase
end

#to_hexObject



13
14
15
# File 'lib/puppet/ssl/digest.rb', line 13

def to_hex
  @digest.hexdigest.scan(/../).join(':').upcase
end

#to_sObject



9
10
11
# File 'lib/puppet/ssl/digest.rb', line 9

def to_s
  "(#{name}) #{to_hex}"
end