Method: Wechat::Cipher#encrypt
- Defined in:
- lib/wechat/cipher.rb
#encrypt(plain, encoding_aes_key) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wechat/cipher.rb', line 8 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 |