Class: Virgil::SDK::Cryptography::Hashes::HashAlgorithm

Inherits:
Object
  • Object
show all
Defined in:
lib/virgil/sdk/cryptography/hashes/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: Crypto::Native::VirgilHash::Algorithm_MD5,
  SHA1: Crypto::Native::VirgilHash::Algorithm_SHA1,
  SHA224: Crypto::Native::VirgilHash::Algorithm_SHA224,
  SHA256: Crypto::Native::VirgilHash::Algorithm_SHA256,
  SHA384: Crypto::Native::VirgilHash::Algorithm_SHA384,
  SHA512: Crypto::Native::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:



76
77
78
79
80
81
# File 'lib/virgil/sdk/cryptography/hashes/hash_algorithm.rb', line 76

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