0

I'm new to Python, using 2.7.12 and am trying to run a very simple script that will hash a 'salt' and simple password using a DES algorithm (I know DES is outdated but this is just to learn how to generate a hash value with a salt). I have this working in the interpreter (i.e. I get the expected hash output 'HX9LLTdc/jiDE') but when I try to run it in my sublime text and/or via command line I get no errors but no output either? I know this is a simple fix but i'm having a blank as to why its not outputting the hash value in my command line after running the script? Any advice, much appreciated.

import passlib.hash

def createHash():

    salt = "HX"
    word = "egg"
    cryptWord = passlib.hash.des_crypt.encrypt(word, salt=salt) 
    print "DES:" + cryptWord
5
  • 4
    okay but do you actually call createHash ? Commented Feb 3, 2017 at 12:00
  • Your script defines a function, createHash, but doesn't actually call it. Commented Feb 3, 2017 at 12:03
  • How do you call the function in the interpreter? Commented Feb 3, 2017 at 12:04
  • Many thanks, was slightly confused on the method call. Works fine now. Commented Feb 3, 2017 at 12:13
  • Many thanks, was slightly confused on the method call. Works fine now. Commented Feb 3, 2017 at 12:13

1 Answer 1

1

You have to call the createHash() method:

if __name__ == "__main__":
    createHash()
Sign up to request clarification or add additional context in comments.

1 Comment

Many thanks bastian, was slightly confused on the method call. Works fine now.

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.