帮助在 php 中创建 md5
我正在尝试使用给定的指令在 php 中创建 md5 值。我似乎无法正确理解,希望您帮助理解说明和代码。
指令是这样说的:
md5 是通过对连接这些字段构建的字符串执行 MD5 计算来构造的。具体来说,MD5 哈希是以下字段的串联:
$user_id
$trans_id
ASCII 的大写 MD5 值 相当于单词“secret”
$amount
$currency
in $status
为了自己计算,请将它们连接起来并对这个字符串进行MD5计算。
I am trying to create an md5 value in php using the instruction given. I can't seem to get it right and would like you help understanding the instructions and the code.
This is what the instructions say:
The md5 is constructed by performing an MD5 calculation on a string built up by concatenating these fields. Specifically the MD5 hash is a concatenation of the following fields:
$user_id
$trans_id
the uppercase MD5 value of the ASCII
equivalent of the word 'secret'$amount
$currency
in $status
In order to calculate it yourself concatenate them and perform a MD5 calculation on this string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我对这个问题的解释。
当然,您可以预先计算
secret
的大写哈希值。但如果是家庭作业,最好像上面那样展示你的作品。That is what I interpreted the question as.
Of course, you could precompute the hash for the uppercase hash of
secret
. But if it's homework, probably best to show your work like above.$result = md5($user_id . $trans_id . strtoupper('secret') . $amount . $currency . $status)
$result = md5($user_id . $trans_id . strtoupper('secret') . $amount . $currency . $status)
我不知道“in $status”到底是什么意思,但它应该看起来像:
I don't know exactly what you mean by "in $status" but it should be something looking :