The problem arose to encrypt data transmitted between client and server using a key without using https (the key is transmitted separately, that’s another story.)
So. Are interested in the mechanism. I know that there is no built-in JS encryption functions, and PHP are many, but not all normal decode UTF8.
Question: Is there a ready-made solutions (if possible with examples) of such a problem?
Overall I found the solution to my problem. I used the algorithm AES CBC 256 bit. Library Gibberish AES (https://github.com/mdp/gibberish-aes) and fork on php (https://github.com/ivantcholakov/gibberish-aes-php/blob/master/GibberishAES.php)