Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the inconsistency between php md5 and js

Shulou Source: shulou.com Published: 2022-06-02 01:18:13 10月04日 Update

Most people do not understand the knowledge points of this article "how to solve the inconsistency between php md5 and js", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to solve the inconsistency between php md5 and js" article.

The inconsistency between php md5 and js is caused by coding, and the solution is to directly convert the Chinese of php and js into characters, such as "md5 ('Chinese content');".

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

What if php md5 and js are inconsistent?

A simple solution to the inconsistency between php md5 and js md5 in Chinese

In Chinese, the discrepancy between the md5 of php and the md5 of js is mainly caused by coding. Not to mention the conversion of coding here, it can be solved by directly converting the Chinese of php and js into characters:

Md5 under php:

Md5 (rawurlencode ('Chinese content'))

Md5 under js:

Md5.hex_md5 (encodeURIComponent ('Chinese content'))

Note: when php transcodes, it cannot use urlencode, it will not transcode spaces, and the encodeURIComponent of js will, which leads to inconsistent results if the parameters contain spaces. Rawurlencode of diphp transcodes spaces just like js.

The above is about the content of this article on "how to solve the inconsistency between php md5 and js". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Tags: Consistency content Chinese spaces coding methods characters that is articles knowledge articles code values parameters most what to do more steps status environment Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Huawei Shulou Tech Info MariaDB