fix: decryption errors
This commit is contained in:
@@ -96,17 +96,23 @@ export const base64Decode = (text: string): string => {
|
|||||||
};
|
};
|
||||||
export const decrypt = (hashString: string) => {
|
export const decrypt = (hashString: string) => {
|
||||||
if (hashString) {
|
if (hashString) {
|
||||||
const hash = JSON.parse(hashString);
|
try {
|
||||||
const decipher = crypto.createDecipheriv(
|
const hash = JSON.parse(hashString);
|
||||||
algorithm,
|
const decipher = crypto.createDecipheriv(
|
||||||
process.env['COOLIFY_SECRET_KEY'],
|
algorithm,
|
||||||
Buffer.from(hash.iv, 'hex')
|
process.env['COOLIFY_SECRET_KEY'],
|
||||||
);
|
Buffer.from(hash.iv, 'hex')
|
||||||
const decrpyted = Buffer.concat([
|
);
|
||||||
decipher.update(Buffer.from(hash.content, 'hex')),
|
const decrpyted = Buffer.concat([
|
||||||
decipher.final()
|
decipher.update(Buffer.from(hash.content, 'hex')),
|
||||||
]);
|
decipher.final()
|
||||||
return decrpyted.toString();
|
]);
|
||||||
|
return decrpyted.toString();
|
||||||
|
} catch (error) {
|
||||||
|
console.log({ decryptionError: error.message })
|
||||||
|
return hashString
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const encrypt = (text: string) => {
|
export const encrypt = (text: string) => {
|
||||||
|
Reference in New Issue
Block a user