Class: TrustpilotBusinessLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/trustpilot-business-links.rb

Constant Summary collapse

ENCRYPTION_CIPHER =
'AES-256-CBC'
HMAC_DIGEST =
'SHA256'

Instance Method Summary collapse

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