Class: Pandexio::SigningAlgorithms

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

Constant Summary collapse

PDX_HMAC_MD5 =
"PDX-HMAC-MD5"
PDX_HMAC_SHA1 =
"PDX-HMAC-SHA1"
PDX_HMAC_SHA256 =
"PDX-HMAC-SHA256"
PDX_HMAC_SHA384 =
"PDX-HMAC-SHA384"
PDX_HMAC_SHA512 =
"PDX-HMAC-SHA512"

Class Method Summary collapse

Class Method Details

.is_v(a) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/signing_algorithms.rb', line 11

def self.is_v(a)

    return !a.nil? && a.is_a?(String) &&
        (a == PDX_HMAC_MD5 ||
        a == PDX_HMAC_SHA1 ||
        a == PDX_HMAC_SHA256 ||
        a == PDX_HMAC_SHA384 ||
        a == PDX_HMAC_SHA512)

end

.to_d(a) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/signing_algorithms.rb', line 22

def self.to_d(a)

    return case a
        when SigningAlgorithms::PDX_HMAC_MD5; OpenSSL::Digest::MD5.new
        when SigningAlgorithms::PDX_HMAC_SHA1; OpenSSL::Digest::SHA1.new
        when SigningAlgorithms::PDX_HMAC_SHA256; OpenSSL::Digest::SHA256.new
        when SigningAlgorithms::PDX_HMAC_SHA384; OpenSSL::Digest::SHA384.new
        when SigningAlgorithms::PDX_HMAC_SHA512; OpenSSL::Digest::SHA512.new
        else raise 'Invalid signing algorithm'
        end

end