用于JS和PHP的相同md5 [英] identical md5 for JS and PHP
问题描述
对于一个小项目,我需要为JS和PHP使用相同的md5哈希值. 我正在使用此 javascript将单词转换为md5(.min版本)
for a small project I need identical md5 hashes for both JS and PHP. Im using this javascript to convert a word to md5 (the .min version)
单词"hello"输入
the word 'hello' outputs in
JS :ec59d44dee488759467970486fc9402d
JS: ec59d44dee488759467970486fc9402d
PHP :5d41402abc4b2a76b9719d911017c592
PHP: 5d41402abc4b2a76b9719d911017c592
因此它们不相同.我尝试使用md5(utf8_encode($word));
代替md5($word);
so they are not identical. I've tried to use md5(utf8_encode($word));
instead of md5($word);
但两者给出的结果相同.
but both gave the same result.
有什么想法吗?非常感谢您的帮助
Any ideas? Help is much appreciated
推荐答案
上的 md5 函数href ="http://phpjs.org/" rel ="noreferrer"> phpjs 给出正确的结果.它取决于 utf8_encode ,因此您也需要它.
The md5 function on phpjs gives the correct results. It is dependent on utf8_encode, so you need that as well.
这篇关于用于JS和PHP的相同md5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!