Method: Wework::Cipher#encrypt

Defined in:
lib/wework/cipher.rb

#encrypt(plain, encoding_aes_key) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wework/cipher.rb', line 14

def encrypt(plain, encoding_aes_key)
  cipher = OpenSSL::Cipher.new(CIPHER)
  cipher.encrypt

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

  cipher.update(plain) + cipher.final
end