Class: TrustpilotBusinessLinks
- Inherits:
-
Object
- Object
- TrustpilotBusinessLinks
- Defined in:
- lib/trustpilot-business-links.rb
Constant Summary collapse
- ENCRYPTION_CIPHER =
'AES-256-CBC'
- HMAC_DIGEST =
'SHA256'
Instance Method Summary collapse
- #encrypt(payload) ⇒ Object
-
#initialize(encryption_key, authentication_key) ⇒ TrustpilotBusinessLinks
constructor
A new instance of TrustpilotBusinessLinks.
Constructor Details
#initialize(encryption_key, authentication_key) ⇒ TrustpilotBusinessLinks
Returns a new instance of TrustpilotBusinessLinks.
9 10 11 12 |
# File 'lib/trustpilot-business-links.rb', line 9 def initialize(encryption_key, authentication_key) @encryption_key = Base64.strict_decode64(encryption_key) @authentication_key = Base64.strict_decode64(authentication_key) end |
Instance Method Details
#encrypt(payload) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/trustpilot-business-links.rb', line 14 def encrypt(payload) encrypted_payload, iv = encrypt_iv(payload) hmac = hmac(iv, encrypted_payload) encode(iv + encrypted_payload + hmac) end |