[ASK] How to implement Yii::$app->security->encryptByKey on Javascript

I want to encrypt some data using Yii::$app->security->encryptByKey and decrypt on javascript and vise versa.

example:

After user login to the system using Restful service. He will received a uniqe token. Every post / get request to API, the data must be encrypted. And server will response with encrypted data.

i already search on google and find this https://www.npmjs.com/package/hkdf, but this is for node js and i dont know how to implement in javascript (browser)

regards

no one know how to implement Yii::$app->security->encryptByKey in javascript?

The library you’ve linked to should work in a browser as well.