问题描述
我需要使用JS和PHP进行哈希处理,但是我需要它们都成为同一哈希值.我只是想知道最好的主意是什么.它必须是安全的,但不能散列敏感数据,因此不需要大量的安全性.
I need to make a hash with JS and PHP but I need them to both work out to be the same hash.I am just wondering what the best idea would be to go about it. it needs to be secure, but its not hashing sensitive data so doesn't need a huge amount of security around it.
谁能给我一些例子
谢谢.
推荐答案
您可以使用MD5:如果输入相同的字符串,则php和JS解决方案应该是相同的. http://pajhome.org.uk/crypt/md5/列出了哈希实现在javascript中,并且在此处中记载了md5的PHP实现.手.
You could use MD5: the php and the JS solution should work out to be the same given the same string input. http://pajhome.org.uk/crypt/md5/ has a list of hash implementations in javascript, and PHP implementations of md5 are documented here, and both have examples at hand.
您需要注意两个函数使用完全相同的输入,否则应该不会太痛苦.
You'll need to be careful that you use the exact same input to both functions, but otherwise it shouldn't be too painful.
这篇关于JS中的哈希== PHP中的哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!