Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49511 > unrolled thread

Re: password protect file

Started byModulok <modulok@gmail.com>
First post2013-06-30 13:25 -0600
Last post2013-07-01 08:25 +1000
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Re: password protect file Modulok <modulok@gmail.com> - 2013-06-30 13:25 -0600
    Re: password protect file gmsiders@gmail.com - 2013-06-30 15:17 -0700
      Re: password protect file Chris Angelico <rosuav@gmail.com> - 2013-07-01 08:25 +1000

#49511 — Re: password protect file

FromModulok <modulok@gmail.com>
Date2013-06-30 13:25 -0600
SubjectRe: password protect file
Message-ID<mailman.4040.1372620358.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Sat, 29 Jun 2013 10:28:47 -0700 (PDT), gmsiders@gmail.com wrote:
> I was wondering if there was a couple of words or things i
> could add to the top of my python script to password
> protect it so that it asks user for the password and then
> after three tries it locks them out or says "access
> denied" and closes/ends the script but if they get it
> wright it proceeds on to the next line of the script total
> noob here any help appreciated

How to correctly implement such features depends on what are you are
protecting. Are you trying to protect another file on the same machine, the
script itself? Is this a server-side script trying to authenticate a web
client? Is this 'kid-sister' level protection or national security level
of protection? We would need more details on what you're trying to
accomplish.

Also, good (i.e. real) security is notoriously difficult to get right. There
are usually pre-built solutions you should make use of instead.

>From your subject line it sounds like you're interested in access control.
If
this is on a controlled system you should instead make use of the pre-built
operating systems access control features such as user accounts, file
permission bits, group policies or Access Control Lists.

If this is in an uncontrolled environment or you just want to protect a
file on
a USB stick from prying eyes you can encrypt the file with a strong
symmetric
cipher like AES. There are existing tools for doing this. Your Python script
could be a wrapper around one of these. (There are certain security
implications to be aware of when doing this.) There's also AES
implementations
available in various pure Python modules. (However these generally are not
FIPS
certified.)

If you are a "total noob" attempting (real) security programming is a bad
idea.
-Modulok-

[toc] | [next] | [standalone]


#49519

Fromgmsiders@gmail.com
Date2013-06-30 15:17 -0700
Message-ID<76742ee4-c5d2-4326-b155-a15c385bb105@googlegroups.com>
In reply to#49511
On Sunday, June 30, 2013 2:25:51 PM UTC-5, Modulok wrote:
> On Sat, 29 Jun 2013 10:28:47 -0700 (PDT), gmsi...@gmail.com wrote:
> 
> > I was wondering if there was a couple of words or things i
> > could add to the top of my python script to password
> 
> > protect it so that it asks user for the password and then
> > after three tries it locks them out or says "access
> 
> > denied" and closes/ends the script but if they get it
> > wright it proceeds on to the next line of the script total
> 
> > noob here any help appreciated
> 
> 
> 
> 
> How to correctly implement such features depends on what are you are
> 
> protecting. Are you trying to protect another file on the same machine, the
> script itself? Is this a server-side script trying to authenticate a web
> 
> client? Is this 'kid-sister' level protection or national security level
> of protection? We would need more details on what you're trying to accomplish.
> 
> 
> 
> Also, good (i.e. real) security is notoriously difficult to get right. There
> are usually pre-built solutions you should make use of instead.
> 
> 
> 
> From your subject line it sounds like you're interested in access control. If
> this is on a controlled system you should instead make use of the pre-built
> 
> operating systems access control features such as user accounts, file
> permission bits, group policies or Access Control Lists.
> 
> 
> 
> If this is in an uncontrolled environment or you just want to protect a file on
> a USB stick from prying eyes you can encrypt the file with a strong symmetric
> 
> cipher like AES. There are existing tools for doing this. Your Python script
> could be a wrapper around one of these. (There are certain security
> 
> implications to be aware of when doing this.) There's also AES implementations
> available in various pure Python modules. (However these generally are not FIPS
> 
> certified.)
> 
> 
> If you are a "total noob" attempting (real) security programming is a bad idea.
> 
> -Modulok-

i just want something simple that basicly asks for a password and then replies to u if you are wrong nothing hevay just for learning exsperience

[toc] | [prev] | [next] | [standalone]


#49520

FromChris Angelico <rosuav@gmail.com>
Date2013-07-01 08:25 +1000
Message-ID<mailman.4047.1372631135.3114.python-list@python.org>
In reply to#49519
On Mon, Jul 1, 2013 at 8:17 AM,  <gmsiders@gmail.com> wrote:
>
> i just want something simple that basicly asks for a password and then replies to u if you are wrong nothing hevay just for learning exsperience
> --

Then your task is pretty easy. Look up these things in the Python docs:

* input (or raw_input if you use Python 2)
* if
* sys.exit

You can do it with those three.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web