Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 27th, 2005, 1:28 PM   #1
Eragon229
Newbie
 
Join Date: Jul 2005
Posts: 14
Rep Power: 0 Eragon229 is an unknown quantity at this point
Question Password Code Problem

Hi. I'm new. I'm trying to use a code to make my program password protected. It keeps saying:
while password != "abcddcba":
NameError: name 'password' is not defined


Thanks.
Eragon229 is offline   Reply With Quote
Old Jul 27th, 2005, 1:50 PM   #2
Riddle
Programmer
 
Riddle's Avatar
 
Join Date: May 2005
Location: Nar Shaddaa
Posts: 42
Rep Power: 0 Riddle is on a distinguished road
Send a message via ICQ to Riddle Send a message via AIM to Riddle Send a message via MSN to Riddle
Insert this somewhere in your code (before this while loop starts)..
password=""
Riddle is offline   Reply With Quote
Old Jul 27th, 2005, 2:00 PM   #3
Eragon229
Newbie
 
Join Date: Jul 2005
Posts: 14
Rep Power: 0 Eragon229 is an unknown quantity at this point
Thanks.
Eragon229 is offline   Reply With Quote
Old Jul 27th, 2005, 6:30 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,825
Rep Power: 5 Sane will become famous soon enough
The password will be hidden in the source code, so people could easily retrieve it. Raise security by creating your own encrypt and decrypt function, then pre-compile the python file.
Sane is offline   Reply With Quote
Old Jul 27th, 2005, 7:10 PM   #5
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
Raise security by creating your own encrypt and decrypt function, then pre-compile the python file.
I couldn't disagree any more. String obfuscation just lulls the user into a false sense of security - much more dangerous than knowing what the risks are. You're going to have to include the code to get the file back to normal, and it doesn't take much time to go from there and retrieve the password. I suppose dynamically constructing the password string would be remotely helpful in that it will make the cracker take longer, or maybe just give up after a while.
Cerulean is offline   Reply With Quote
Old Jul 29th, 2005, 12:15 AM   #6
hydroxide
Programmer
 
Join Date: Apr 2005
Posts: 73
Rep Power: 4 hydroxide is on a distinguished road
1/ You should compare encrypted/hashed strings only
2/ You should use library encryption rather than hand rolling your own.
3/ You should use library functions for other things too.

Do the following in the Interactive Interpreter (etc)
import md5
print md5.md5("InsertYourPasswordHere").hexdigest()

copy the output (in this case 66e37426a7ff13e2957b2eed7c26039b, but obviously it'll be different for a different password)

Then in your user code use:
from getpass import getpass
from md5 import md5
MYPASSWORDHASH = "66e37426a7ff13e2957b2eed7c26039b" # or whatever
def get_password():
    for i in range(3):
        password = md5(getpass("Enter your password: "))
        if password.hexdigest() == MYPASSWORDHASH:
            return True
    return False

def main():
    if get_password():
        print "Success"
        # do something here
    else:
        print "Failure"
        # do something else here

if __name__ == "__main__":
    main()

--OH.
[Ok, md5 is theoretically breakable... =]
hydroxide is offline   Reply With Quote
Old Jul 27th, 2005, 7:18 PM   #7
Riddle
Programmer
 
Riddle's Avatar
 
Join Date: May 2005
Location: Nar Shaddaa
Posts: 42
Rep Power: 0 Riddle is on a distinguished road
Send a message via ICQ to Riddle Send a message via AIM to Riddle Send a message via MSN to Riddle
Bah... if he's asking this question, I think that he is most likely not scripting something which really needs this security. I mean yeah, it's dandy and all, but is it needed?
Riddle is offline   Reply With Quote
Old Jul 27th, 2005, 8:29 PM   #8
Eragon229
Newbie
 
Join Date: Jul 2005
Posts: 14
Rep Power: 0 Eragon229 is an unknown quantity at this point
I'm not that advanced, just starting python. The least I can do is prevent access to the source code. How? I have no clue. I don't have to worry as long as that particular person does not have Python installed in the system. It'll open using command prompt.
Eragon229 is offline   Reply With Quote
Old Jul 27th, 2005, 9:15 PM   #9
Riddle
Programmer
 
Riddle's Avatar
 
Join Date: May 2005
Location: Nar Shaddaa
Posts: 42
Rep Power: 0 Riddle is on a distinguished road
Send a message via ICQ to Riddle Send a message via AIM to Riddle Send a message via MSN to Riddle
Quote:
Originally Posted by Eragon229
I'm not that advanced, just starting python. The least I can do is prevent access to the source code. How? I have no clue. I don't have to worry as long as that particular person does not have Python installed in the system. It'll open using command prompt.
If the person does not have Python installed on the system, it will not run- unless you use py2exe. In which case you'll need to give them the python DLL with it. Some people will say that py2exe is hard to use, but it's really not.. I dunno what their deal is.
Riddle is offline   Reply With Quote
Old Jul 28th, 2005, 6:00 AM   #10
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,825
Rep Power: 5 Sane will become famous soon enough
Quote:
I couldn't disagree any more. String obfuscation just lulls the user into a false sense of security... ... ...
That's why I said you then precompile it. But if you precompile it without making an encrypted string, you can still find the password inside the compiled file. At least if you encrypt it they'll have to guess how you did it, or find whatever thing is used to decompile python files.

He said he's new to Python, so that would probably be the easiest way for him.
Sane is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:09 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC