Please I need help getting the exact md5 value of this python script in PHP
The Python script
def md5code(params):
params = {'identifier': ' ', 'amount': '0.0', 'code': 'UNIA'}
req = dict([[key, params.get(key, '')] for key in ['code', 'identifier', 'amount']])
secret = '2fd0bba6b1774ed391c1ff8467f52a5d'
text = ":".join([req[x] for x in ['code', 'identifier', 'amount']] + secret)
return md5(text).hexdigest().upper()
The return value is: 5D316CD2311678A1B12F6152988F3097
The PHP script
$secret = '2fd0bba6b1774ed391c1ff8467f52a5d';
$code = 'UNIA';
$valid_institution = array('amount' => '0.0', 'code' => $code, 'identifier' => ' ');
foreach($valid_institution as $k => $v) {
$text = implode(":", $v[$k] + $secret);
}
print strtoupper(hash("md5", $text));
The return value is: D41D8CD98F00B204E9800998ECF8427E
I’m expecting the PHP script to return an exact md5 value, but it is not.
Any suggestions will be appreciated.
Thanks
ok, seems you’re using foreach in a wrong way. Try this: