简体   繁体   中英

Single mechanism for reversible encryption in PHP and JS

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?

I've solved this problem with pidCrypt which has a working RSA implementation in JavaScript. There is also jCryption which I've never used.

I recently had to implement this in virtually the only case where it's valid to do so: We were storing data offline in the application cache, and a non-negotiable business requirement stated that it be encrypted while there. Unless you're doing something similar, the answer is to use SSL and throw out any hope of implementing a JS solution to this problem. You need SSL to securely transmit the code to the browser, or any encryption you do there is fundamentally insecure.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM