# Need Help with some JS code

**URL:** <https://forum.adalo.com/t/need-help-with-some-js-code/28881>\
**Category:** Get Help\
**Created:** [June 29, 2022, 8:45pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881 "2022-06-29T20:45:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HApp](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@HApp](https://forum.adalo.com/u/HApp)\
**Post date:** [June 29, 2022, 8:45pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/1 "2022-06-29T20:45:23Z")

</div>

I tried to make hash (sha256) using this code:

const hmac = require(‘crypto-js/hmac-sha256’);

const body = {  
order\_id: ‘123’,  
currency: ‘uah’,  
wallet\_type: ‘ecom’,  
amount: 10,  
payway: ‘card’,  
// …  
};

const signature = hmac(JSON.stringify(body), ‘secretKey’)  
.toString();

I used Pragmaflow Java script Component.

Unfortunately simply nothing happens ☹

Is it possible to use cryptographic functions in this component? Maybe someone knows how to do it… I need to create hashed signature to be used in API authentication process for payment provider…

---

<div class="post-metadata">

**Author:** ![njimmy10](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/njimmy10/32/23489_2.png) [@njimmy10](https://forum.adalo.com/u/njimmy10)\
**Post date:** [June 29, 2022, 9:07pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/2 "2022-06-29T21:07:31Z")

</div>

Hello,

I can help you, what exactly are you asking for? a sha256 working code?

---

<div class="post-metadata">

**Author:** ![HApp](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@HApp](https://forum.adalo.com/u/HApp)\
**Post date:** [June 29, 2022, 9:57pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/3 "2022-06-29T21:57:00Z")

</div>

Hi! Thanks for your reply!

Pragmaflow team released JS component for Adalo, you can find it here: [https://adalo.pragmaflowservers.com/install-component](https://adalo.pragmaflowservers.com/install-component)

It is called Arbitrary Javascript

I tried to use it (it executes JS code), and I used the code

const hmac = require(‘crypto-js/hmac-sha256’);

const body = {  
order\_id: ‘123’,  
currency: ‘uah’,  
wallet\_type: ‘ecom’,  
amount: 10,  
payway: ‘card’,  
// …  
};

const signature = hmac(JSON.stringify(body), ‘secretKey’)  
.toString();

I tried to get encrypted string (sha256 or sha512) with parameters (from body).

For some reason that code did not work in the component and I don’t know the reason…

---

<div class="post-metadata">

**Author:** ![HApp](https://avatars.discourse-cdn.com/v4/letter/h/e9c0ed/32.png) [@HApp](https://forum.adalo.com/u/HApp)\
**Post date:** [June 29, 2022, 10:00pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/4 "2022-06-29T22:00:06Z")

</div>

I am trying to make encrypted auth signature for later use in API requests

Here is the API docs if you ask.  
[https://docs.crosspay.net](https://docs.crosspay.net)

First of all it says:  
Signature

How to sign?

You need to generate a signature on your side, based on request data and your secret key. We use `HMAC-SHA256`.

---

<div class="post-metadata">

**Author:** ![njimmy10](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/njimmy10/32/23489_2.png) [@njimmy10](https://forum.adalo.com/u/njimmy10)\
**Post date:** [June 29, 2022, 10:14pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/5 "2022-06-29T22:14:42Z")

</div>

> [@HApp](#):
>
> const hmac = require(‘crypto-js/hmac-sha256’);

Simple JS like this component doesn’t allow you to install package; crypto-js/hmac-sha256 is an npm package, so you can’t do it this way

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [July 9, 2022, 10:14pm UTC](https://forum.adalo.com/t/need-help-with-some-js-code/28881/6 "2022-07-09T22:14:42Z")

</div>

Closed on July 9, 2022, 10:14pm UTC

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