user1657841
user1657841

Reputation: 21

Use of deprecated module md5

I am using the following code in python:

from hashlib import md5
user_code = string.upper( md5.new(user_str).hexdigest() )

and the warning is

DeprecationWarning: the md5 module is deprecated; use hashlib instead

Could you please help how to update this code so that is runs also on the current version of python?

Thanks!

Upvotes: 1

Views: 4018

Answers (1)

moopet
moopet

Reputation: 6185

You don't specify which version of python you're using. I'll assume you're using 2.7 not 3

import hashlib

user_str = "foo"    
user_code = hashlib.md5(user_str).hexdigest().upper()

From the docs: http://docs.python.org/library/hashlib.html#module-hashlib

Upvotes: 3

Related Questions