Class: R509::MessageDigest

Inherits:
Object
  • Object
show all
Defined in:
lib/r509/message_digest.rb

Overview

MessageDigest allows you to specify MDs in a more friendly fashion

Constant Summary

KNOWN_MDS =

a list of message digests that this class understands

['SHA1','SHA224','SHA256','SHA384','SHA512','DSS1','MD5']
DEFAULT_MD =

this constant defines the default message digest if it is not supplied or an invalid digest is passed

'SHA1'

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (MessageDigest) initialize(arg = nil)

A new instance of MessageDigest

Parameters:

  • arg (String, OpenSSL::Digest) (defaults to: nil)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/r509/message_digest.rb', line 16

def initialize(arg=nil)
  if arg.kind_of?(String)
    @name = arg.downcase
    @digest = translate_name_to_digest
  elsif arg.nil?
    @name = DEFAULT_MD
    @digest = translate_name_to_digest
  else
    @digest = arg
    @name = translate_digest_to_name
  end
end

Instance Attribute Details

- (Object) digest (readonly)

Returns the value of attribute digest



13
14
15
# File 'lib/r509/message_digest.rb', line 13

def digest
  @digest
end

- (Object) name (readonly)

Returns the value of attribute name



13
14
15
# File 'lib/r509/message_digest.rb', line 13

def name
  @name
end