add isEncrypted check to decrypt as a safeguard
This commit is contained in:
parent
a7e36e98d7
commit
692dd5aa21
1 changed files with 5 additions and 1 deletions
|
|
@ -17,7 +17,7 @@ const encrypt = async (data: string) => {
|
|||
return data;
|
||||
}
|
||||
|
||||
if (data.startsWith(encryptionPrefix)) {
|
||||
if (isEncrypted(data)) {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
@ -38,6 +38,10 @@ const encrypt = async (data: string) => {
|
|||
* Given an encrypted string, decrypts it using the salt stored in the string
|
||||
*/
|
||||
const decrypt = async (encryptedData: string) => {
|
||||
if (!isEncrypted(encryptedData)) {
|
||||
return encryptedData;
|
||||
}
|
||||
|
||||
const secret = await Bun.file(RESTIC_PASS_FILE).text();
|
||||
|
||||
const parts = encryptedData.split(":").slice(1); // Remove prefix
|
||||
|
|
|
|||
Loading…
Reference in a new issue