#  encrypt information

**URL:** <https://forums.fusetools.com/t/encrypt-information/6923>\
**Category:** How-to Discussions\
**Created:** [June 8, 2016, 8:36pm UTC](https://forums.fusetools.com/t/encrypt-information/6923 "2016-06-08T20:36:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Res](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@Daniel\_Res](https://forums.fusetools.com/u/Daniel_Res)\
**Post date:** [June 8, 2016, 8:36pm UTC](https://forums.fusetools.com/t/encrypt-information/6923/1 "2016-06-08T20:36:45Z")

</div>

hello community!!!

I want to implement encryption in my URL before sending the FETCH;

I’m trying to add libraries(AesUtil.js) to Fuse unsuccessfully,

```ux
<App>
<!--MainView.ux-->
  <JavaScript File="js/AesUtil.js" ux:Global="AesUtil" />

//MainView.js
var Observable = require('FuseJS/Observable');
var AesUtil = require('AesUtil');

```

but it does not recognize me methods

It shows me the following errer

> ReferenceError: CryptoJS is not defined in Fuse.Reactive.JavaScript

It could support me, I 'm adding bad the library?

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [June 10, 2016, 11:16am UTC](https://forums.fusetools.com/t/encrypt-information/6923/2 "2016-06-10T11:16:35Z")

</div>

Do you have a testcase you can send over? You need to remember to do `module.exports = somecryptObj` in youy AesUtil.js file maybe?

---

<div class="post-metadata">

**Author:** ![Sahal\_Zain](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@Sahal\_Zain](https://forums.fusetools.com/u/Sahal_Zain)\
**Post date:** [June 10, 2016, 2:05pm UTC](https://forums.fusetools.com/t/encrypt-information/6923/3 "2016-06-10T14:05:27Z")

</div>

It’s either you haven’t load the required dependency (CryptoJS) properly, or your library (AesUtil.js) or the CryptoJS depend on Web Crypto API which is not supported by fusetools.

Alternatively you can use another cryptography library such as libsodium.js, but you still need to implement the random bytes function which is depend on Web Crypto API originally.

---

<div class="post-metadata">

**Author:** ![Daniel\_Res](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@Daniel\_Res](https://forums.fusetools.com/u/Daniel_Res)\
**Post date:** [July 14, 2016, 6:18pm UTC](https://forums.fusetools.com/t/encrypt-information/6923/4 "2016-07-14T18:18:29Z")

</div>

thanks for your answers.

Hello Sahal Zain. thank for your suggestion; I am taking up the theme, take borrow your code jejeje

```auto
 result.value = 'test'
 window.crypto = {};
 window.crypto.getRandomValues = require('cryptopoly');

    var wrappers = require('libsodium-wrappers');
    var publicKey = 'ROTdAnYLeTFkxMSnEuV1aVw88rnoqxadWixz1xHqtRg=';
    var secretKey = 'ROTdAnYLeTFkxMSnEuV1aVw88rnoqxadWixz1xHqtRg=';
    var outputFormat = 'base64';

 function encrypt(){
    var cipher = wrappers.crypto_box_seal(result.value,wrappers.from_base64(publicKey),outputFormat);
    result.value = cipher;
 }

 function descrypt(){

    var respuesta = wrappers.crypto_box_seal_open(result.value,wrappers.from_base64(publicKey),wrappers.from_base64(secretKey),outputFormat);
    resulDese.value = respuesta;
  console.log("resulDese.value== "+resulDese.value);
 }

```

I could not decrypt the message; I throw error

ERROR: Name: ScriptError Error message: Uncaught Error File name: libsodium-wrappers.js Line number: 299 Source line: throw new Error(err); JS stack trace: Error at \_free\_and\_throw\_error (libsodium-wrappers.js:299:23) at Object.crypto\_box\_seal\_open (libsodium-wrappers.js:1627:3) at descrypt (MainView.ux:23:34)

you could help me.

---

<div class="post-metadata">

**Author:** ![Vicker\_Leung](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/vicker_leung/32/392_2.png) [@Vicker\_Leung](https://forums.fusetools.com/u/Vicker_Leung)\
**Post date:** [June 27, 2017, 10:49am UTC](https://forums.fusetools.com/t/encrypt-information/6923/5 "2017-06-27T10:49:09Z")

</div>

I was trying to encrypt some data as well using JSEncrypt but no luck yet. Does anyone got something that works?
