Comments (1)
可以的,你在创建的时候,那里有很多模板,其中一个就是这个代码。
function onRequest(request, response, modules) {
var appId = 'wx094ede192e7e64b5'
var sessionKey = request.body.sessionKey || 'QQiAgWqKv4hu4Lkn6XE0Jw=='
var encryptedData = request.body.encryptedData || 'FyTPbuir1sSNPvaPxxZiUKatMUuuSi16OlkM7mB+U3pxvdCJ7zUrTz9dnZGnSmi8grDYw/g3GU9bCNUrRGQZ2BORLGKXhCEFBme4n0XJAL/uXwIeivFsZIBkaEfFrAh/DvJGibeCDkfO2zHcSOKTsDwtEBbGdJUz/N3o2WG33m27V72t30UUe+CE26rucjM1zJqHkHEsSr9YOZlFodE0+Q=='
var iv = request.body.iv || '74ExWKy/mxV22YeWaJOVVw=='
var groupid = groupIdParse(modules, sessionKey, encryptedData, iv)
var jsongid = JSON.parse(groupid);
response.end(groupid);
return;
function groupIdParse(modules, sessionKey, encryptedData, iv) {
var crypto = modules.oCrypto;
var sessionKey = new Buffer(sessionKey, 'base64'); //new Base64().decode(sessionKey);
encryptedData = new Buffer(encryptedData, 'base64'); //new Base64().decode(encryptedData);
iv = new Buffer(iv, 'base64'); //new Base64().decode(iv)
var result = '';
try {
// 解密
var decipher = crypto.createDecipheriv('aes-128-cbc', sessionKey, iv)
// 设置自动 padding 为 true,删除填充补位
decipher.setAutoPadding(true)
var decoded = decipher.update(encryptedData, 'binary', 'utf8')
decoded += decipher.final('utf8')
result = decoded;
// decoded = JSON.parse(decoded)
} catch (err) {
throw new Error('Illegal Buffer123' + err)
}
return result;
}
}
from wechatappdemo.
Related Issues (5)
- 请问如何使用云端逻辑进行模糊查询? HOT 1
- 嘻嘻嘻 HOT 1
- 视频和代码版本没对应啊,下载后不能直接使用啊 HOT 1
- 聊天功能不可用
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wechatappdemo.