Module: Kutils::CryptoUtils
- Defined in:
- lib/utils/crypto_utils.rb
Overview
CryptoUtils provides common hash and encoding utilities.
Class Method Summary collapse
-
.base64_encode(str) ⇒ String
Base64 encode string.
-
.hmac_sha256(data, key) ⇒ String
Calculate HMAC-SHA256 hex digest.
-
.md5(str) ⇒ String
Calculate MD5 hex digest.
Class Method Details
.base64_encode(str) ⇒ String
Base64 encode string
32 33 34 |
# File 'lib/utils/crypto_utils.rb', line 32 def self.base64_encode(str) Base64.strict_encode64(str) end |
.hmac_sha256(data, key) ⇒ String
Calculate HMAC-SHA256 hex digest
25 26 27 |
# File 'lib/utils/crypto_utils.rb', line 25 def self.hmac_sha256(data, key) OpenSSL::HMAC.hexdigest('SHA256', key, data) end |
.md5(str) ⇒ String
Calculate MD5 hex digest
17 18 19 |
# File 'lib/utils/crypto_utils.rb', line 17 def self.md5(str) Digest::MD5.hexdigest(str) end |