(text: string, key: string = config.secret)
| 14 | |
| 15 | // DES 解密 |
| 16 | export function desDecrypt(text: string, key: string = config.secret) { |
| 17 | key = |
| 18 | key.length >= 8 ? key.slice(0, 8) : key.concat('0'.repeat(8 - key.length)); |
| 19 | const keyHex = new Buffer(key); |
| 20 | const cipher = crypto.createDecipheriv('des-cbc', keyHex, keyHex); |
| 21 | let c = cipher.update(text, 'base64', 'utf8'); |
| 22 | c += cipher.final('utf8'); |
| 23 | return c; |
| 24 | } |