Updates
This commit is contained in:
@@ -8,6 +8,7 @@ type Param = {
|
||||
encryptedString: string;
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -17,9 +18,10 @@ export default function decrypt({
|
||||
encryptedString,
|
||||
encryptionKey,
|
||||
encryptionSalt,
|
||||
debug,
|
||||
}: Param) {
|
||||
if (!encryptedString?.match(/./)) {
|
||||
console.log("Encrypted string is invalid");
|
||||
if (debug) console.log("Encrypted string is invalid");
|
||||
return encryptedString;
|
||||
}
|
||||
|
||||
@@ -32,12 +34,12 @@ export default function decrypt({
|
||||
} = grabKeys({ encryptionKey });
|
||||
|
||||
if (!encrptKey?.match(/.{8,}/)) {
|
||||
console.log("Decrption key is invalid");
|
||||
if (debug) console.log("Decrption key is invalid");
|
||||
return encryptedString;
|
||||
}
|
||||
|
||||
if (!salt?.match(/.{8,}/)) {
|
||||
console.log("Decrption salt is invalid");
|
||||
if (debug) console.log("Decrption salt is invalid");
|
||||
return encryptedString;
|
||||
}
|
||||
|
||||
@@ -51,9 +53,9 @@ export default function decrypt({
|
||||
decrypted += decipher.final("utf8");
|
||||
return decrypted;
|
||||
} catch (error: any) {
|
||||
console.log("Error in decrypting =>", error.message);
|
||||
console.log("encryptedString =>", encryptedString);
|
||||
global.ERROR_CALLBACK?.(`Error Decrypting data`, error as Error);
|
||||
if (debug) {
|
||||
console.log("Error Decrypting data", error as Error);
|
||||
}
|
||||
return encryptedString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ export default function encrypt({
|
||||
return encrypted;
|
||||
} catch (error: any) {
|
||||
console.log("Error in encrypting =>", error.message);
|
||||
global.ERROR_CALLBACK?.(`Error Encrypting Data`, error as Error);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user