![Hivecrypt thumbnail.png](https://ipfs.io/ipfs/QmZ44f49mDr746uqisE11de6WXa3ojka4oecYTsvTo6BNb)
Are you getting the following error message when trying to encrypt or decrypt a Hive memo in ElectronJS or React Native using [hive-js](https://gitlab.syncad.com/hive/hive-js)? Perhaps looking for something that works for your framework that you're using when building your cutting-edge Hive DApp?
![Screenshot 20201122 at 12.04.23 PM.png](https://files.peakd.com/file/peakd-hive/techcoderx/kpahmLHh-Screenshot202020-11-2220at2012.04.2320PM.png)
Introducing [Hivecrypt](https://github.com/techcoderx/hivecrypt), a module that you can import into a wide range of JavaScript environments, including desktop and mobile app frameworks like ElectronJS, that wouldn't otherwise work with existing libraries.
Adapted from this [pull request](https://peakd.com/hive-139531/@tngflx/contribution-to-dhive-added-memo-encryption-and-decrypt-feature) on [dhive](https://gitlab.syncad.com/hive/dhive) that was never merged into `master` (plus the major help from this [file](https://github.com/mahdiyari/hive-tx-js/blob/master/helpers/crypto.js)), Hivecrypt was built on [Crypto-JS](https://github.com/brix/crypto-js) that works on virtually any latest JavaScript environments, unlike the implementation on [hive-js](https://gitlab.syncad.com/hive/hive-js) and the pull request mentioned above, that uses the [crypto](https://nodejs.org/api/crypto.html) NodeJS module that only works on certain environments.
## How to use?
Hivecrypt can be installed from `npm` with the following command:
```
npm i hivecrypt
```
It can also be imported into the browser by including the following script tag in your HTML file, where Hivecrypt will be available through `window.hivecrypt`:
```
```
Once installed, it may be used for encrypting and decrypting memos just like how it is done with [hive-js](https://gitlab.syncad.com/hive/hive-js), but works in more environments.
```
const hivecrypt = require('hivecrypt') // CommonJS
let encrypted = hivecrypt.encode('privatekey1','publickey2','#somesecretmessage')
let decrypted = hivecrypt.decode('privatekey2',encrypted)
console.log(encrypted,decrypted)
```
It might not be built with optimizing for the smallest package size in mind, but at least it is something that is usable for devs.
[![Hive witness footer 2.png](https://ipfs.io/ipfs/QmVTNReuWzvLtY5sucfunQ2m9JpLWroYrXrcztpVsZq3sG)](https://hivesigner.com/sign/account-witness-vote?witness=techcoderx&approve=1)
**UPDATE**: Upon further testing apparently it is not fully cross-compatible with `hive-js`, perhaps that is why that PR never got merged into `master`. But at least it would still be useful for my upcoming OneLoveIPFS v2 upgrade.
See: Hivecrypt: JavaScript module for Hive memo encrypt/decrypt on wide range of environments
by
@techcoderx