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


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

password and username code

Started byÖmer sarı <sari.omer.1989@gmail.com>
First post2016-03-05 13:52 -0800
Last post2016-03-06 12:44 -0500
Articles 5 — 4 participants

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


Contents

  password and username code Ömer sarı <sari.omer.1989@gmail.com> - 2016-03-05 13:52 -0800
    Re: password and username code Ben Finney <ben+python@benfinney.id.au> - 2016-03-06 10:36 +1100
    Re: password and username code John Gordon <gordon@panix.com> - 2016-03-06 14:40 +0000
    Re: password and username code Ömer sarı <sari.omer.1989@gmail.com> - 2016-03-06 06:55 -0800
      Re: password and username code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-03-06 12:44 -0500

#104115 — password and username code

FromÖmer sarı <sari.omer.1989@gmail.com>
Date2016-03-05 13:52 -0800
Subjectpassword and username code
Message-ID<1ed89545-f102-4538-bfe2-9d0e3dac8cf5@googlegroups.com>
hi , all , l m fresh user and l m trying to learn python by doing practice but l got stuck in that , l need help , l m a beginner and  l learn some basic things so far so, plz take in consideration that before command .

here is my code trial:
#login by using username and password

loop=1

paword=['1234','5678']
pawordch=["1","2","3","4","5","6","7","8","9","0","/","(",")","*","%","&","!","a","b","c","d","e","f","g","h","k","l","m","n","o","p","r","s","t","y","v","y","z","x"]
name=['murat','can','omer','owrasa']

while loop==1 :
    print "welcome my website,plz if you have an account , just login , otherwise , register plz"
    username=raw_input("username:")
    password=raw_input("password:")
    if username in name and password in paword:
        print "login is successful, and continue page 2"
    else :
        print" please register"
        login_username=raw_input ("username:")
        login_password=raw_input("password:")
        for login_password in pawordch:
            if login_password in pawordch :
                name.append(login_username)
                paword.append(login_password)
                print "relogin ,plz"
                print name ,"",paword
                login_username=raw_input ("username:")
                login_password=raw_input("password:")
                if login_username in name and login_password in paword:
                    print "login successful , proceed to page 2"
                    break
                    
                else:
                    print "login is unseccesful and please make sure your username and password is correct"
                    
        
.l would like to do samething when we login a website. l want program if username is not registered , register first , then store it , and l want program ask for some specific characters , like 1,2,3../,%. 

thanks for any clearification in advance 

[toc] | [next] | [standalone]


#104116

FromBen Finney <ben+python@benfinney.id.au>
Date2016-03-06 10:36 +1100
Message-ID<mailman.234.1457221208.20602.python-list@python.org>
In reply to#104115
Ömer sarı <sari.omer.1989@gmail.com> writes:

> hi , all , l m fresh user and l m trying to learn python by doing
> practice but l got stuck in that , l need help , l m a beginner and  l
> learn some basic things so far so, plz take in consideration that
> before command .

Welcome! You have chosen a good language for learning.

We have a forum explicitly dedicated to collaboratively learning Python
<URL:https://mail.python.org/mailman/listinfo/tutor>, you may want to go
there and participate.

Please note that communication is important when programming: please
take care to write English. Using “l m”, or “plz”, leads to a needlessly
difficult-to-read message. Thanks!

-- 
 \         “For a sentimentalist is simply one who desires to have the |
  `\    luxury of an emotion without paying for it.” —Oscar Wilde, _De |
_o__)                                                 Profundis_, 1897 |
Ben Finney

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


#104143

FromJohn Gordon <gordon@panix.com>
Date2016-03-06 14:40 +0000
Message-ID<nbhfgl$q2e$1@reader1.panix.com>
In reply to#104115
In <1ed89545-f102-4538-bfe2-9d0e3dac8cf5@googlegroups.com> =?UTF-8?B?w5ZtZXIgc2FyxLE=?= <sari.omer.1989@gmail.com> writes:

> l want program if username is not registered, register first,
> then store it, and l want program ask for some specific characters,
> like 1,2,3../,%. 

What is your process for finding out if a name is registered?  There
are lots of possible ways to do it.  Do you have one in mind?

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

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


#104148

FromÖmer sarı <sari.omer.1989@gmail.com>
Date2016-03-06 06:55 -0800
Message-ID<cbebb763-e613-48cb-b68c-b126f1551dc2@googlegroups.com>
In reply to#104115
5 Mart 2016 Cumartesi 23:52:58 UTC+2 tarihinde Ömer sarı yazdı:
> hi , all , l m fresh user and l m trying to learn python by doing practice but l got stuck in that , l need help , l m a beginner and  l learn some basic things so far so, plz take in consideration that before command .
> 
> here is my code trial:
> #login by using username and password
> 
> loop=1
> 
> paword=['1234','5678']
> pawordch=["1","2","3","4","5","6","7","8","9","0","/","(",")","*","%","&","!","a","b","c","d","e","f","g","h","k","l","m","n","o","p","r","s","t","y","v","y","z","x"]
> name=['murat','can','omer','owrasa']
> 
> while loop==1 :
>     print "welcome my website,plz if you have an account , just login , otherwise , register plz"
>     username=raw_input("username:")
>     password=raw_input("password:")
>     if username in name and password in paword:
>         print "login is successful, and continue page 2"
>     else :
>         print" please register"
>         login_username=raw_input ("username:")
>         login_password=raw_input("password:")
>         for login_password in pawordch:
>             if login_password in pawordch :
>                 name.append(login_username)
>                 paword.append(login_password)
>                 print "relogin ,plz"
>                 print name ,"",paword
>                 login_username=raw_input ("username:")
>                 login_password=raw_input("password:")
>                 if login_username in name and login_password in paword:
>                     print "login successful , proceed to page 2"
>                     break
>                     
>                 else:
>                     print "login is unseccesful and please make sure your username and password is correct"
>                     
>         
> .l would like to do samething when we login a website. l want program if username is not registered , register first , then store it , and l want program ask for some specific characters , like 1,2,3../,%. 
> 
> thanks for any clearification in advance

for example : some websites ask for a password including some specific characters , like one letter, one ( /,%,*,),(,...) so my purpose is to create a program .first ask for username , then password , then check them , if they don't match with stored (username and password ) , make them register and during that , store "username " and "password" but "password must be including 1 letter , 1 sign , and less than 10 length , more than 4 . l don't know how to do it.as l tried many things but  l got error . l hope it would be more explaintory as my English is not good enough.thanks for any advice in advance

best regards.

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


#104161

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2016-03-06 12:44 -0500
Message-ID<mailman.259.1457286250.20602.python-list@python.org>
In reply to#104148
On Sun, 6 Mar 2016 06:55:04 -0800 (PST), Ömer sar?
<sari.omer.1989@gmail.com> declaimed the following:


>for example : some websites ask for a password including some specific characters , like one letter, one ( /,%,*,),(,...) so my purpose is to create a program .first ask for username , then password , then check them , if they don't match with stored (username and password ) , make them register and during that , store "username " and "password" but "password must be including 1 letter , 1 sign , and less than 10 length , more than 4 . l don't know how to do it.as l tried many things but  l got error . l hope it would be more explaintory as my English is not good enough.thanks for any advice in advance

	A proper website will NOT "first ask for username, then password", but
will present a form with fields for both items -- and maybe a button for
new registrations.

	Granted, testing algorithms using a console does mean having to prompt
for things in sequence (in which case I'd put "new register" first, since
asking for a username/password for someone not in the system before letting
them register is annoying)...

	You should also not test the username for validity and then ask for
password -- that way leads to hacking as one can test names until they get
a valid one, and then test passwords with just that name. Instead you
accept both username and password before checking anything, and return
success/failure on the full combination.

	Usernames and hashed passwords should be stored in some database, so
you can come back to it later. You do not store plain text passwords; you
store a one-way hash of the password (read the Python library reference on
"crypt"). 

	If you forbid commas and spaces from usernames and passwords, you could
use a single console input statement for everything

login = raw_input("Enter username,password or 'register' if new=> ")
if login.lower().startswith("register"):
	# do new user registration stuff
	# get user name
	# get password
	# confirm password
	# generate random salt
	# crypt (salt+password)
	#save uname, crypted hash in database
else:
	uname, pword = login.split(",")
	if not uname or not pword:
		#user did not supply both fields
		#error exit
	#fetch record for "uname" from database
	#if no record, error exit
	#pull salt from hashed password, 
	#compute crypt(salt+pword)
	#compare new hash to database record
	#if no match, error exit

	NOTE: a website will also be using cookies (another randomized value
that can be stored in a database with stuff like auto-logoff time) to
maintain session history of a valid login. All web pages after login will
request the cookie (that had been sent to the browser on successful login)
to be returned, the server than checks the cookie against the one it stored
in a database to see if the user is still valid. The database may also have
record of what page the user is one, links to (for an order site) the
current shopping cart, etc..
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [standalone]


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


csiph-web