RSA encrypt and decrypt?

basically, given a public and private key, I wanted to encrypt and decrypt the data. I tried to do this using the custom javascript and since it is impossible to add src’s such as

<script src="https://cdnjs.cloudflare.com/ajax/libs/jsencrypt/2.3.1/jsencrypt.js"></script>

I have to copy the whole lib code in the custom javascript function. However, I am not able to make it work in AppGyver and got some error like “TypeError: null is not an object (evaluating…”. I have tested the code using other javascript runtime and it works fine there.

So, I have no idea and it is difficult to debug. I wonder if anyone has done something like this (encrypt and decrypt) before and is there a solution for that?