Method: Wechat::Cipher#pack

Defined in:
lib/wechat/cipher.rb

#pack(content, app_id) ⇒ Object

app_id or corp_id



34
35
36
37
38
39
40
# File 'lib/wechat/cipher.rb', line 34

def pack(content, app_id)
  random = SecureRandom.hex(8)
  text = content.dup.force_encoding('ASCII-8BIT')
  msg_len = [text.length].pack('N')

  encode_padding("#{random}#{msg_len}#{text}#{app_id}")
end