Skip to content

Commit

Permalink
feat(js-storefrontaware-utils): Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed Oct 4, 2022
1 parent c53fb0c commit 3afa310
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@crystallize/js-storefrontaware-utils",
"license": "MIT",
"version": "0.2.2",
"version": "0.2.3",
"author": "Crystallize <[email protected]> (https://crystallize.com)",
"contributors": [
"Sébastien Morel <[email protected]>"
Expand Down
4 changes: 2 additions & 2 deletions src/cypher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ export function encryptValue(value: string, secretKey: string, algorithm: string
}

export function decryptValue(value: string, secretKey: string, algorithm: string): string {
if (value.includes(':')) {
if (value?.includes(':')) {
const [initVector, encryptedData] = value.split(':');
const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(initVector, 'hex'));
let decryptedData = decipher.update(encryptedData, 'hex', 'utf-8');
decryptedData += decipher.final('utf8');
return decryptedData;
}
return value;
return value || '';
}

/**
Expand Down

0 comments on commit 3afa310

Please sign in to comment.