Joe
Joe

Reputation: 1772

php - need help converting a python command to php code

I'm using the python hashlib to get a condensed md5 value using the following command, can someone help me out with a compatible function?

hashlib.md5('my string').hexdigest()

Upvotes: 1

Views: 3723

Answers (2)

fahad.hasan
fahad.hasan

Reputation: 912

echo md5('apple');
// => 1f3870be274f6c49b3e31a0c6728957f

produces the same result as

require 'digest/md5';
print Digest::MD5.hexdigest('apple');
# => 1f3870be274f6c49b3e31a0c6728957f

Upvotes: 1

Rakesh
Rakesh

Reputation: 82785

$string = 'my string'
$encoded_string = md5($string);

Upvotes: 5

Related Questions