Method: Wework::Cipher#decrypt

Defined in:
lib/wework/cipher.rb

#decrypt(msg, encoding_aes_key) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/wework/cipher.rb', line 26

def decrypt(msg, encoding_aes_key)
  cipher = OpenSSL::Cipher.new(CIPHER)
  cipher.decrypt

  cipher.padding = 0
  key_data = Base64.decode64(encoding_aes_key + '=')
  cipher.key = key_data
  cipher.iv = [key_data].pack('H*')

  plain = cipher.update(msg) + cipher.final
  decode_padding(plain)
end