首页
社区
课程
招聘
[未解决,已结帖] 一个微信小程序,WS的,有js代码,吧收到消息解密,发送消息加密翻译成别的语言 500.00雪花
发表于: 2021-5-17 09:41 3194

[未解决,已结帖] 一个微信小程序,WS的,有js代码,吧收到消息解密,发送消息加密翻译成别的语言 500.00雪花

2021-5-17 09:41
3194

一个微信小程序,WS的,有js代码,吧收到消息解密,发送消息加密翻译成别的语言

 

加解密翻译成:C++/易语言/python 都可以
若预算不足联系Q:756036加预算
下面是附件及加解密函数关键字

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
////-------------------------------------------------收到消息
c._ws.onMessage(function(a) {
                    c.OnEventReceiveData(a.data)
                });
//-------------------------------------------------OnEventReceiveData
OnEventReceiveData: function(a) {
                if (this._socketState == SOCKET_STATE_CONNECTED && a) {
                    var b = new MsgHeader(!1);
                    b.from(a);
                    switch (this.UnEscapeMessage(b)) {
                        case UNESCAPEMSG_ERROR:
                            this.OnEventClose(0);
                            break;
                        case UNESCAPEMSG_IGNORE:
                            break;
                        default:
                            b.wMessageID ==
                                MSG_KEEPALIVE ? (this._bSentKeepAlive = !1, a = MsgKeepAliveReply.from(a).dwTimeStamp, this._dwPing = DateEx.getCurDateMilliSeconds() - a) : this._messageProcessor && this._messageProcessor.OnProcessMessage(b)
                    }
                }
            },
//-------------------------------------------------UnEscapeMessage
UnEscapeMessage: function(a) {
                var b = a.byFlag,
                    c = a.getOriginBuffer(),
                    d = c.byteLength - a.byHeaderOffset;
                if (d && b & MSG_HEADER_FLAG_COMPRESS && !isNative()) {
                    b = void 0;
                    d = new Uint8Array(c, a.byHeaderOffset, d);
                    try {
                        b = (new Zlib.Inflate(d)).decompress()
                    } catch (e) {
                        b = new Uint8Array(c, 0, c.byteLength), log(this.bin2hex(b)), log(this.bin2hex(d)), b = void 0, log("\u6570\u636e\u89e3\u538b\u5931\u8d25,err:", e.message)
                    }
                    if (b &&
                        b instanceof Uint8Array) {
                        var c = new Uint8Array(c, 0, a.byHeaderOffset),
                            d = a.byHeaderOffset + b.length,
                            f = new Uint8Array(d);
                        f.set(c, 0);
                        f.set(b, a.byHeaderOffset);
                        a.from(f.buffer);
                        a.wLen = d
                    } else return UNESCAPEMSG_ERROR
                }
                return UNESCAPEMSG_OK
            },
//-------------------------------------------------加密函数
EscapeMessage: function(a) {
                var b = a.byFlag;
                if (!(b & MSG_HEADER_FLAG_FILLED)) {
                    b & MSG_HEADER_FLAG_OFFSET || (a.byHeaderOffset = 8);
                    var c = a.getPosition() - a.byHeaderOffset;
                    if (c) {
                        var d = new Uint8Array(a.getOriginBuffer(), a.byHeaderOffset, c);
                        if (b & MSG_HEADER_FLAG_COMPRESS) {
                            var e = void 0;
                            try {
                                e = Zlib.Deflate.compress(d)
                            } catch (f) {
                                e =
                                    void 0, log("\u6d88\u606f\u6570\u636e\u538b\u7f29\u51fa\u9519, err:", f.message)
                            }
                            if (e && e instanceof Uint8Array && e.length < c) {
                                for (var g = 0; g < e.length; g++) d[g] = e[g];
                                c = e.length;
                                a.wLen = e.length + a.byHeaderOffset;
                                a.updatePosition(a.wLen)
                            } else a.byFlag ^= MSG_HEADER_FLAG_COMPRESS
                        }
                        b & MSG_HEADER_FLAG_ENCODE && (a.byFlag ^= MSG_HEADER_FLAG_ENCODE);
                        if (b & MSG_HEADER_FLAG_MASK) {
                            b = a.byMask;
                            b = Math.floor(256 * Math.random());
                            for (g = 0; g < c; g++) d[g] ^= b, b ^= g % 256;
                            a.byMask = b
                        }
                    }
                    a.byFlag |= MSG_HEADER_FLAG_FILLED
                }
            }

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 2373
活跃值: (1046)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
2
简单看了下。加解密应该就是zlib压缩和解压缩吧
2021-5-18 22:57
0
游客
登录 | 注册 方可回帖
返回
//