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.



6
7
8
9
# File 'lib/puppet/ssl/digest.rb', line 6

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

Instance Attribute Details

#digestObject (readonly)

Returns the value of attribute digest.



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

def digest
  @digest
end

Instance Method Details

#nameObject



19
20
21
# File 'lib/puppet/ssl/digest.rb', line 19

def name
  @digest.name.upcase
end

#to_hexObject



15
16
17
# File 'lib/puppet/ssl/digest.rb', line 15

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

#to_sObject



11
12
13
# File 'lib/puppet/ssl/digest.rb', line 11

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