Question about encryption in Python
Pablo Bleyer Kocik
pbleyer at dgf.uchile.cl
Wed Feb 9 23:01:49 EST 2000
flounder wrote:
> Ok, what I want to do is use the crypt() function in a Perl program to
> encrypt a string then I want to beable to use a pyhton program to
> compare a entered password with the one encrypted in Perl and
> visa-versa. So what I am saying is does Python have a module that is
> the same to Perl's so I can do this. I know I could use MD5 or
> something in Perl then it would work but then I will have to install a
> new module in perl and I don't have access to do that on the server I
> am using. I am mainly just messing around and would just like to know
> if there is something I could use.
>
> Thanks alot
>
> --
> Flounder
>
> Just another C/C++, Perl, Pyhton, Tcl, Bash ... hacker
>
Perl's crypt() and Python's crypt.crypt() call the system's crypt in
Unix.
E.g.
Perl: print crypt("Hola","mu"); => muYo7cPyJD2p2
Python: import crypt; crypt.crypt("Hola","mu") => 'muYo7cPyJD2p2'
--
Pablo Bleyer Kocik |"And all this science I don't understand
pbleyer | It's just my job five days a week
@dgf.uchile.cl | A rocket man, a rocket man..." - Elton John
from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
'-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d
while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce(
lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1)))
More information about the Python-list
mailing list