Class: Virgil::Crypto::HashAlgorithm

Inherits:
Object
  • Object
show all
Defined in:
lib/virgil/crypto/hash_algorithm.rb

Overview

Enumeration containing supported Algorithms

Defined Under Namespace

Classes: UnknownAlgorithmException

Constant Summary collapse

MD5 =
:MD5
SHA1 =
:SHA1
SHA224 =
:SHA224
SHA256 =
:SHA256
SHA384 =
:SHA384
SHA512 =
:SHA512
ALGORITHMS_TO_NATIVE =
{
  MD5: Core::VirgilHash::Algorithm_MD5,
  SHA1: Core::VirgilHash::Algorithm_SHA1,
  SHA224: Core::VirgilHash::Algorithm_SHA224,
  SHA256: Core::VirgilHash::Algorithm_SHA256,
  SHA384: Core::VirgilHash::Algorithm_SHA384,
  SHA512: Core::VirgilHash::Algorithm_SHA512
}

Class Method Summary collapse

Class Method Details

.convert_to_native(algorithm) ⇒ Integer

Converts algorithm enum value to native value

Parameters:

Returns:

  • (Integer)

    Native library algorithm id.

Raises:



73
74
75
76
77
78
79
# File 'lib/virgil/crypto/hash_algorithm.rb', line 73

def self.convert_to_native(algorithm)
  if ALGORITHMS_TO_NATIVE.has_key?(algorithm)
    return ALGORITHMS_TO_NATIVE[algorithm]
  end

  raise UnknownAlgorithmException("KeyPairType not found: #{algorithm}")
end