Skip to content

Commit

Permalink
Added JSON.parse to encryption/decryption examples (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimonaR-MC authored Aug 9, 2024
1 parent 94b5d04 commit 81f4f6e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ Example using the configuration [above](#configuring-the-jwe-encryption):
```js
const response = {};
response.request = { url: "/resource1" };
response.body =
response.body = JSON.parse(
"{" +
' "path": {' +
' "to": {' +
Expand All @@ -348,7 +348,7 @@ response.body =
" }" +
" }" +
" }" +
"}";
"}");
const jwe = new (require("mastercard-client-encryption").JweEncryption)(config);
let responsePayload = jwe.decrypt(response);
```
Expand Down Expand Up @@ -398,11 +398,11 @@ const config = {
Example:

```js
const payload =
const payload = JSON.parse(
"{" +
' "sensitive": "this is a secret",' +
' "sensitive2": "this is a super secret!"' +
"}";
"}");
const jwe = new (require("mastercard-client-encryption").JweEncryption)(config);
//
let responsePayload = jwe.encrypt("/resource1", header, payload);
Expand Down Expand Up @@ -446,10 +446,10 @@ const config = {
Example:

```js
const encryptedPayload =
const encryptedPayload = JSON.parse(
"{" +
' "encryptedData": "eyJraWQiOiI3NjFiMDAzYzFlYWRlM….Y+oPYKZEMTKyYcSIVEgtQw"' +
"}";
"}");
const jwe = new (require("mastercard-client-encryption").JweEncryption)(config);
let responsePayload = jwe.decrypt(encryptedPayload);
```
Expand Down Expand Up @@ -525,11 +525,11 @@ Example of decryption:
```js
const response = {};
response.request = { url: "/resource1" };
response.body =
response.body = JSON.parse(
"{" +
' "encryptedData": "eyJraWQiOiI3NjFiMDAzYzFlYWRlM….Y+oPYKZEMTKyYcSIVEgtQw",' +
' "notSensitive": "not a secret"' +
"}";
"}");
const jwe = new (require("mastercard-client-encryption").JweEncryption)(config);
let responsePayload = jwe.decrypt(response);
```
Expand Down

0 comments on commit 81f4f6e

Please sign in to comment.