0

I have a python program that accesses SQL databases with the database login currently encoded in base64 in a text file. I'd like to encode the login instead using MD5 and store it in a config file, but after some research, I couldn't find much on the topic. Could someone point me in the right direction on where to start?

2
  • 1
    Encrypting, encoding and hashing are very different things. Commented Jun 24, 2016 at 14:54
  • The database story has not really anything to do with the question, does it? :-) Commented Jun 24, 2016 at 14:57

2 Answers 2

1

MD5, unfortunately, is a hash signature protocol, not an encryption protocol. It is used to generate strings that are used to detect even the very-slightest change to the value from which the MD5 hash was produced. But . . . (by design) . . . you cannot recover the value that was originally used to produce the signature!

If you are working in a corporate, "intra-net" setting, consider using LDAP (Microsoft OpenDirectory) or some other form of authorization/authentication, in lieu of "passwords." In this scenario, the security department authorizes your application to do certain things, and they provide you with an otherwise-meaningless token with which to do it. The database uses the presented token, along with other rules controlled only by the security department, to recognize your script and to grant selected access to it. The token is "useless if stolen."

If you do still need to use passwords, you'll need to find a different way to securely store them. MD5 cannot be used.

Sign up to request clarification or add additional context in comments.

Comments

0

See https://docs.python.org/3.5/library/hashlib.html

import hashlib
print( hashlib.md5(b"stackoverflow").hexdigest() )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.