mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix: add validation for encrypted data format in decryptString function
This commit is contained in:
@@ -114,6 +114,9 @@ export function decryptString(data: string, secretKey?: Buffer): Response {
|
||||
secretKey = Buffer.from(Env.SECRET_KEY, 'hex');
|
||||
}
|
||||
try {
|
||||
if (!isEncrypted(data)) {
|
||||
throw new Error('The data was not in an expected encrypted format');
|
||||
}
|
||||
const [_, ivHex, encryptedHex] = decodeURIComponent(data).split(':');
|
||||
const iv = Buffer.from(ivHex, 'base64');
|
||||
const encrypted = Buffer.from(encryptedHex, 'base64');
|
||||
|
||||
Reference in New Issue
Block a user