Keywords: HarmonyOS, Hongmeng, ArkTs, JSEncrypt, encryption, third-party library
HarmonyOS supports fewer third-party library files due to initial problems. Plug-ins installed using npm install cannot be used normally, resulting in the inability to use more third-party libraries to meet your needs. Of course, we can also use some alternative methods to force the use of these third-party libraries.
JSEncrypt_3.3.2 tool class has been submitted to Gitee:luvi/jsencrypt3.3.2
start
Copy the downloaded JSEncrypt node_moudules code, read through the author's code, and find out the exported dependency files we need. Open the code and easily find what we need.
or
How to use it in the project
Create a new utils directory in the project to store the downloaded third-party library. Import the modules in the library into the code and use them according to the normal usage process.
const key = "" //公钥
const en = new JSEncrypt()
en.setPublicKey(key)
const ret = en.encrypt("你好")
console.log(ret+" 加密后结果")
All roads lead to Rome