-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-encrypt-key.js
More file actions
55 lines (47 loc) · 1.8 KB
/
test-encrypt-key.js
File metadata and controls
55 lines (47 loc) · 1.8 KB
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
// 测试新的 Encrypt Key
const { AESCipher } = require('@larksuiteoapi/node-sdk');
// 您提供的密钥
const ENCRYPT_KEY = 'sJoVjUwk11X2RHNbnOUqpb';
const VERIFICATION_TOKEN = 'kititgrCMZ7ZXhI2wyO59fnBavJg6MMI';
// 测试数据
const testEncrypt = 'wGOZREUK7MosZatqz8rLpt0xYlpm/FpEBVOLf4R9tCMKRkzJTFWLII4S4xKh0/7NxtDB9L2yqBNAWq2g7X1AVoHl4F5/Wmpx1HA4zs5G0JLoEQPovwmm8H6Z0V1Z42GoFkviK4d7b4bK+mo4X3Ems6+/rDzoBWdlB4t+/7euhbRBOfgBAswMvqCwGHYEq0zi';
console.log('=== 测试 Lark Encrypt Key ===\n');
// 测试 Encrypt Key
console.log('1. 使用 Encrypt Key:', ENCRYPT_KEY);
try {
const cipher1 = new AESCipher(ENCRYPT_KEY);
const decrypted1 = cipher1.decrypt(testEncrypt);
console.log('✓ 解密成功!');
console.log('解密结果:', decrypted1);
try {
const parsed = JSON.parse(decrypted1);
console.log('JSON 内容:', parsed);
if (parsed.challenge) {
console.log('Challenge 值:', parsed.challenge);
}
} catch (e) {
console.log('JSON 解析失败');
}
} catch (error) {
console.log('✗ 解密失败:', error.message);
}
console.log('\n2. 使用 Verification Token:', VERIFICATION_TOKEN);
try {
const cipher2 = new AESCipher(VERIFICATION_TOKEN);
const decrypted2 = cipher2.decrypt(testEncrypt);
console.log('✓ 解密成功!');
console.log('解密结果:', decrypted2);
try {
const parsed = JSON.parse(decrypted2);
console.log('JSON 内容:', parsed);
if (parsed.challenge) {
console.log('Challenge 值:', parsed.challenge);
}
} catch (e) {
console.log('JSON 解析失败');
}
} catch (error) {
console.log('✗ 解密失败:', error.message);
}
console.log('\n如果其中一个成功,请使用成功的密钥更新 .env 文件');
console.log('LARK_ENCRYPT_KEY=使用成功的密钥');