Class: As2::DigestSelector

Inherits:
Object
  • Object
show all
Defined in:
lib/as2/digest_selector.rb

Class Method Summary collapse

Class Method Details

.for_code(code) ⇒ Object



21
22
23
# File 'lib/as2/digest_selector.rb', line 21

def self.for_code(code)
  @map[normalized(code)] || OpenSSL::Digest::SHA1
end

.normalized(code) ⇒ Object



25
26
27
28
# File 'lib/as2/digest_selector.rb', line 25

def self.normalized(code)
  # we may receive 'sha256', 'sha-256', or 'SHA256'.
  code.to_s.strip.downcase.gsub(/[^a-z0-9]/, '')
end

.valid?(code) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/as2/digest_selector.rb', line 17

def self.valid?(code)
  @map[normalized(code)]
end

.valid_codesObject



13
14
15
# File 'lib/as2/digest_selector.rb', line 13

def self.valid_codes
  @map.keys
end