Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scripts): AG-50 refactored utils function #44

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions lib/crypto-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@ export function encryptString(
execSyncOptions,
);

const en = encrypted.toString().split("\n");
const chiper = en[0].split(" ")[1];
const nonce = en[1].split(" ")[1];
const response: Encrypted = JSON.parse(encrypted.toString());

return {
chiper,
nonce,
};
return response;
} catch (e) {
console.error(e);
throw new Error("Error encrypting string");
Expand Down Expand Up @@ -81,12 +76,9 @@ export function decryptString(
execSyncOptions,
);

const de = decrypted.toString().split("\n");
const message = de[0].substring(
de[0].indexOf("message: ") + "message: ".length,
);
const response: Decrypted = JSON.parse(decrypted.toString());

return { message };
return response;
} catch (e) {
throw new Error("Error decrypting string");
}
Expand Down
Loading