token刷新bug修复
This commit is contained in:
33
decrypt-test.js
Normal file
33
decrypt-test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
// 简单的解密脚本
|
||||
const { sm4 } = require('sm-crypto');
|
||||
|
||||
function sm4Decrypt(key, value, mode = "hex") {
|
||||
try {
|
||||
const decrypted = sm4.decrypt(value, key, {
|
||||
mode: 'ecb',
|
||||
cipherType: mode === 'hex' ? 'hex' : 'base64',
|
||||
padding: 'pkcs#5'
|
||||
});
|
||||
return decrypted;
|
||||
} catch (e) {
|
||||
console.error('sm4 decrypt error:', e);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
const key = '86C63180C1306ABC4D8F989E0A0BC9F3';
|
||||
const encryptedData = '6e38a482a83c7a9ff7c1787cd06a473c5f479b15028ccd4d64925596ea3c6b652f3c05bd5e8fd9f60c72cc1e7141c3717b86c8368cd20816cb8b121c23a3e80d7b57ea5bb6354e0935de2d195b0a8acb';
|
||||
|
||||
console.log('密钥:', key);
|
||||
console.log('加密数据:', encryptedData);
|
||||
|
||||
const decrypted = sm4Decrypt(key, encryptedData, 'hex');
|
||||
console.log('\n解密结果:', decrypted);
|
||||
|
||||
try {
|
||||
const jsonObj = JSON.parse(decrypted);
|
||||
console.log('\nJSON解析结果:', JSON.stringify(jsonObj, null, 2));
|
||||
} catch (e) {
|
||||
console.log('\n不是有效的JSON格式');
|
||||
}
|
||||
Reference in New Issue
Block a user