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