[Tutor] CGI problem.

Mark Kels mark.kels at gmail.com
Tue Nov 9 18:06:15 CET 2004

On Mon, 08 Nov 2004 18:49:28 -0500, Kent Johnson
<kent_johnson at skillsoft.com> wrote:
> At 09:40 PM 11/8/2004 +0200, Mark Kels wrote:
> >I'm sorry about the last post, I was cmparing 124 and 123.
> >here is what I get when I do it right (124 and 124):
> >\xc8\xff\xe9\xa5\x87\xb1&\xf1R\xed=\x89\xa1F\xb4E      (filepass)
> >'\xc8\xff\xe9\xa5\x87\xb1&\xf1R\xed=\x89\xa1F\xb4E'      (repr(userpass))
> >Now its easy to just take off the ' chars from the string, and I hope
> >it will work...
> I just noticed the md5 function hexdigest(). If you use this instead of
> digest() you will get a nice clean hex string right at the start and
> dispense with all this \x and repr() stuff.
> Kent
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

It works!!
Here is the complete (and working) code:

import cgi
import cgitb; cgitb.enable()
import md5
import re
form = cgi.FieldStorage()
print "Content-type: text/html\n\n"
def printhtml():
   print """
      <form><input name="pass" type="text"></form>
def checkpass():
   filepass=x.readline() # The password in the file is already digested.
   if userpass==filepass:
       print "OK, come in."
       print "Wrong password, try again!"

if form.has_key("pass"):

Thanks to all who helped me!!

More information about the Tutor mailing list