Dear list members, I have a Perl script which crypts a password using a clearteaxt password and a username.
Example: username = '[EMAIL PROTECTED]' password = 'root' The crypted password is: 'roK20XGbWEsSM' The crypted password always starts with the first 2 characters of the username (here: 'ro' from '[EMAIL PROTECTED]'). The Perl script contains this code and I am wondering how I can do this in Python: ################################################################################# my $CryptedPw = ''; # md5 pw if ($Self->{ConfigObject}->Get('AuthModule::DB::CryptType') && $Self->{ConfigObject}->Get('AuthModule::DB::CryptType') eq 'md5') { $CryptedPw = unix_md5_crypt($Pw, $Param{UserLogin}); } # crypt pw else { # crypt given pw (unfortunately there is a mod_perl2 bug # on RH8 - check if # crypt() is working correctly) :-/ if (crypt('root', '[EMAIL PROTECTED]') eq 'roK20XGbWEsSM') { $CryptedPw = crypt($Pw, $Param{UserLogin}); } else { $Self->{LogObject}->Log( Priority => 'notice', Message => "The crypt() of your mod_perl(2) is not working correctly! Update mod_perl!", ); my $TempUser = quotemeta($Param{UserLogin}); my $TempPw = quotemeta($Pw); my $CMD = "perl -e \"print crypt('$TempPw', '$TempUser');\""; open (IO, " $CMD | ") || print STDERR "Can't open $CMD: $!"; while (<IO>) { $CryptedPw .= $_; } close (IO); chomp $CryptedPw; } } ################################################################################# What do I have to do in Python to create the crypted password 'roK20XGbWEsSM' by using '[EMAIL PROTECTED]' for username and 'root' for password? I tried: >>> username = '[EMAIL PROTECTED]' >>> password = 'root' >>> import crypt >>> crypt.crypt(username, password) 'roowueH.vq6VM' >>> This creates 'roowueH.vq6VM' but not 'roK20XGbWEsSM'. :-( Thanks in advance, Nico -- http://mail.python.org/mailman/listinfo/python-list