[Tutor] Simple password generation

2005-05-23 Thread Trey Beck
Hi. First post.

I'm trying to (more or less) copy the functionality of quepasa  
(http://quepasa.sourceforge.net), a simple password generation script  
that builds passwords from a combination of a passphrase and another  
string (like a domain name).

If you enter the same passphrase and string, you should get the same  
password (in case you forget...).

I've added a bit so that if neither a passphrase nor a string is  
entered, the function returns a random (or somewhat random) eight- 
character string.

Am i on the right track here? (I'm brand new to sha and so forth.)  
Criticisms?

Thx!
Trey

---


import sha, re, base64, string
from random import choice

def QuePasa (salt='', passphrase='', length=8):
 salted = passphrase + salt
 newpasswd = ''

 if (salted):
 hash = sha.new(salted).digest()
 # for now, strip non-alphanumeric characters
 newpasswd = re.sub(r'\W', '', base64.encodestring(hash)) 
[:length]
 else:
 chars = string.letters + string.digits
 for i in range(length):
 newpasswd = newpasswd + choice(chars)

 return newpasswd

if __name__ == "__main__":
 sites = ['thissite.com','thatsite.com', 'theothersite.com','']
 passphrase = 'all your base are belong to us'

 for i in range(10):
 for site in sites:
 print "%s : %s" % (site, QuePasa(passphrase, site))

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Web browser

2005-06-10 Thread Trey Beck
Why do you need to use a web browser rather than doing this  
programmatically?

On Jun 10, 2005, at 9:56 PM, Ismael Garrido wrote:

> Hello.
>
> I've been looking around for a web browser either written in  
> python, or
> with python bindings.
> What I need to do is load a web-page, enter a password-protected site
> and follow certain links, it needs to have frames and follow the  
> refresh
> meta. I'm running winxp, python 2.4
>
> At first I thought about using a python web browser, but none I could
> find had frames support. The most promising ones were quite old  
> too. And
> one that was completly written in Python used and old version and just
> kept crashing in python 2.4.
> Then, I thought about using some browser with bindings. I've looked  
> all
> over and found about nothing. Mozilla and its xpcom just seems quite
> hard and I'm not sure if that does the job I want. I tried finding COM
> bindings in other browsers, but I coudn't understand them and make  
> them
> work...
>
> Any suggestion would be greatly appreciated.
> Ismael
> _______
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


---
Trey Beck, Director of Covert Operations
Ohtogo

My hCard: http://www.ohtogo.com/hcard.htm
AIM: samuelbeckt



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor