# EMR integration decryption using JavaScript

**URL:** <https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698>\
**Category:** API and Webhooks\
**Created:** [March 3, 2021, 12:52am UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698 "2021-03-03T00:52:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henrik.Nordberg](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/henrik.nordberg/32/23916_2.png) [@Henrik.Nordberg](https://devforum.zoom.us/u/Henrik.Nordberg)\
**Post date:** [March 3, 2021, 12:52am UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698/1 "2021-03-03T00:52:23Z")

</div>

We are trying to follow [Integrating Zoom Into Your EMR Platform](https://medium.com/@eddie.soliman/integrating-zoom-into-your-emr-platform-692d112def40) to decrypt data passed to us from Epic.

Assumptions:  
Encryption algorithm: AES-128 with an empty IV  
Encrypted data is BASE64 encoded and URL encoded before passed to us as the ‘data=’ parameter.  
Secret key is BASE64 encoded.

Our server is NodeJS and we are trying to decrypt using the built in Crypto library that comes with Node. Our code goes something like this:

```
import crypto from 'crypto';

const decodeBuffer = buffer => (Buffer.from( decodeURIComponent(buffer), 'base64' ));

export const decrypt = cipherText => {
	let decodedText = decodeBuffer(cipherText);
	let decipher = crypto.createDecipher(algorithm, decodeBuffer(secretKey));
	let plainText = decipher.update(decodedText);
	plainText = Buffer.concat([plainText, decipher.final()]);
	return plainText.toString();
}

```

This fails during the .final() call with a ‘bad decrypt’ error. If we call this on a cipher text obtained using this matching encrypt() function it works fine:

```
export const encrypt = text => {
	const cipher = crypto.createCipher(algorithm, decodeBuffer(secretKey));
	const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
	return encodeURIComponent(encrypted.toString('base64'));
};

```

I suspect that the assumption around the encoding of the key and/or encrypted data is false. It there documentation about this somewhere?

Thanks,  
Henrik

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [March 3, 2021, 11:52pm UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698/2 "2021-03-03T23:52:42Z")

</div>

Hey @Henrik.Nordberg,

Thank you for reaching out to the Zoom Developer Forum. I’m not sure on these details off the top of my head so I’ve reached out to an internal resource to see if I can confirm how this can be done.

I’ll be sure to update you here when I have more information.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![Henrik.Nordberg](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/henrik.nordberg/32/23916_2.png) [@Henrik.Nordberg](https://devforum.zoom.us/u/Henrik.Nordberg)\
**Post date:** [March 4, 2021, 6:43pm UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698/3 "2021-03-04T18:43:09Z")

</div>

Just to note: I’ve also tried using the secretKey (which is our Zoom account secret key) as is, without base64 decoding it first and that also does not work.

---

<div class="post-metadata">

**Author:** ![MaxM](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maxm/32/42303_2.png) [@MaxM](https://devforum.zoom.us/u/MaxM)\
**Post date:** [March 5, 2021, 12:49am UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698/4 "2021-03-05T00:49:10Z")

</div>

Hey @Henrik.Nordberg,

Thank you for the update. I’m still working to gather information here to make sure that I’m providing the right steps to decrypt this data. It sounds like we may also need to update the article that you provided.

Would you be able to send an email to [developersupport@zoom.us](mailto:developersupport@zoom.us) with a link to this thread so that I can track the issue and follow-up with you there?

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 4, 2021, 10:50am UTC](https://devforum.zoom.us/t/emr-integration-decryption-using-javascript/44698/5 "2021-04-04T10:50:09Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
