wechat_data_crypt 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/wechat_data_crypt.rb +24 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e872f9649d71952cd4ce501b1018b0f67cf58b24
|
4
|
+
data.tar.gz: 9779928712c9e97feb8017d1cd894f0d595398d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77c59eca3d17847044a46e8b5d34113f5046f067492cc2d22d984889946d7d3f9c8ec7aeb9602d513a49983468ac78b93161921ab4444bb65aa6304b823f9a5f
|
7
|
+
data.tar.gz: babd2264de46f17864c4218f4186ba658fba03dc3c30f8fd3e6e13c17619c84809a1f6277bd952b13949529d8edf346ef216a687db22d4a9c997b45345c612ea
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "openssl"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
class DecodeWechatEncrypted
|
6
|
+
attr_accessor :appId, :sessionKey
|
7
|
+
def initialize appId, sessionKey
|
8
|
+
self.appId = appId
|
9
|
+
self.sessionKey = sessionKey
|
10
|
+
end
|
11
|
+
|
12
|
+
def decryptData encryptedData, iv
|
13
|
+
sessionKey = Base64.decode64(self.sessionKey)
|
14
|
+
encryptedData = Base64.decode64(encryptedData)
|
15
|
+
iv = Base64.decode64(iv)
|
16
|
+
cipher = OpenSSL::Cipher.new("AES-128-CBC")
|
17
|
+
cipher.decrypt
|
18
|
+
cipher.key = sessionKey
|
19
|
+
cipher.iv = iv
|
20
|
+
|
21
|
+
result = cipher.update(encryptedData) + cipher.final
|
22
|
+
JSON.parse result
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wechat_data_crypt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 纪亚荣
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 微信小程序对称解密Ruby实现
|
14
|
+
email: 583255925@qq.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/wechat_data_crypt.rb
|
20
|
+
homepage: https://github.com/jiyarong/wechat_data_crypt
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.12
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: 微信小程序对称解密
|
44
|
+
test_files: []
|