views:

63

answers:

3

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.

+1  A: 
$yourMd5 = md5($user_id . $trans_id . strtoupper(md5('secret')) . $amount . $currency . $status);

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.

alex
A: 

$result = md5($user_id . $trans_id . strtoupper('secret') . $amount . $currency . $status)

bogdanvursu
A: 

I don't know exactly what you mean by "in $status" but it should be something looking :

echo md5($user_id.$trans_id.strtoupper(md5(ord(s).ord(e).ord(c).ord(r).ord(e).ord(t))).$amount.$currency.$status);
Kaaviar
I think the "ASCII equivalent" just means between characters mapping from 97 to 122. But I may be wrong.
alex