正在显示
2 个修改的文件
包含
6 行增加
和
13 行删除
| @@ -36,21 +36,14 @@ class DingTalkEncryptor { | @@ -36,21 +36,14 @@ class DingTalkEncryptor { | ||
| 36 | const cropIdBuf = Buffer.from(this.corpId); | 36 | const cropIdBuf = Buffer.from(this.corpId); |
| 37 | const padCount = 32 - (randomBuf.length + textLenBuf.length + plainTextBuf.length + cropIdBuf.length) % 32; | 37 | const padCount = 32 - (randomBuf.length + textLenBuf.length + plainTextBuf.length + cropIdBuf.length) % 32; |
| 38 | const padBuf = Buffer.from(new Array(padCount).fill(padCount)); | 38 | const padBuf = Buffer.from(new Array(padCount).fill(padCount)); |
| 39 | - const finalBuf = Buffer.concat([randomBuf, textLenBuf, plainTextBuf, cropIdBuf, padBuf]); | ||
| 40 | - console.log("randomBuf@@@",randomBuf.toString('utf-8')) | ||
| 41 | - console.log("plainTextBuf@@@",plainTextBuf.toString('utf-8')) | ||
| 42 | - console.log("textLenBuf@@@",textLen,textLenBuf.toString('hex')) | ||
| 43 | - console.log("cropIdBuf@@@",cropIdBuf.toString('utf-8')) | ||
| 44 | - console.log("padCount@@@",padCount ) | ||
| 45 | - console.log("padBuf@@@",padBuf) | ||
| 46 | - console.log("finalBuf@@@",finalBuf.toString('hex')) | ||
| 47 | - | ||
| 48 | - const encrypted = CryptoJS.AES.encrypt(finalBuf.toString('hex'), this.keySpec, { | 39 | + const finalBuf = Buffer.concat([randomBuf, textLenBuf, plainTextBuf, cropIdBuf, padBuf]); |
| 40 | + | ||
| 41 | + const encrypted = CryptoJS.AES.encrypt( CryptoJS.enc.Hex.parse(finalBuf.toString('hex')), this.keySpec, { | ||
| 49 | iv: this.iv, | 42 | iv: this.iv, |
| 50 | mode: CryptoJS.mode.CBC, | 43 | mode: CryptoJS.mode.CBC, |
| 51 | padding:CryptoJS.pad.Pkcs7 | 44 | padding:CryptoJS.pad.Pkcs7 |
| 52 | }); | 45 | }); |
| 53 | - return encrypted.toString(CryptoJS.enc.Base64); | 46 | + return encrypted.toString(); |
| 54 | } catch (e) { | 47 | } catch (e) { |
| 55 | console.log(e) | 48 | console.log(e) |
| 56 | throw new DingTalkEncryptException(900007); | 49 | throw new DingTalkEncryptException(900007); |
| 1 | { | 1 | { |
| 2 | "name": "dingtalk-encrypt", | 2 | "name": "dingtalk-encrypt", |
| 3 | - "version": "2.0.0", | 3 | + "version": "1.0.0", |
| 4 | "description": "dingTalk Encrypt Nodejs Version.", | 4 | "description": "dingTalk Encrypt Nodejs Version.", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| @@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
| 13 | "encrypt", | 13 | "encrypt", |
| 14 | "decrypt" | 14 | "decrypt" |
| 15 | ], | 15 | ], |
| 16 | - "author": "senique,zhubg520", | 16 | + "author": "fan", |
| 17 | "license": "Apache-2.0", | 17 | "license": "Apache-2.0", |
| 18 | "homepage": "http://gitlab.workai.com.cn/fanwh/dingtalk-encrypt", | 18 | "homepage": "http://gitlab.workai.com.cn/fanwh/dingtalk-encrypt", |
| 19 | "dependencies": { | 19 | "dependencies": { |
请
注册
或
登录
后发表评论