[Tutor] what module to use for encrypt passwords????

alan.gauld@bt.com alan.gauld@bt.com
Thu, 22 Aug 2002 13:45:21 +0100


> I have to do a simple, not extremely secure GUI in tkinter requesting
> for users and their passwords. My question is what module should I use
> for encrypt passwords? it has to be a module availabe either 
> in Windows & Linux.

It depends on what these are for.

If you want to actually access the user ID and password for the OS 
then trying to write a portable solution will be "challenging". The 
passwords are stored in different places, in different formats and 
without a standard API.

If OTOH you only want to implement user security for your own 
applications then its relatively easy to do. Simply find a 
crypt() function. Store the encrypted password in a file 
somewhere. Next time the user enters their password encrypt it 
and compare the two encrypted forms. If they are the same then 
the user gets access.

There are lots of encrypting functions you can use depending 
on the level of security. One of thec simplest(and least secure!) 
is to shift the bits of the characters circularly by N(often 3) bits.
Not secure but easy to implement and portable over ASCII/UTF-8 systems.

OTOH if you want full security you might have to write a wrapper 
around the native OS crypt() functions. But be aware that these 
are not portable across platforms. indeed they may not even be 
portable on the same platform across countries since many places 
have limits on the allowed strength of encryption (don't want to 
make it too hard for the feds to crack the code, do we?! :-)

HTH,

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld