Hello all,

I have an abend when my perl script is finished. Everything it had to do was 
done but It seems it doesn't know where to return correctly anymore.   I 
want to use this code to read an encrypted password in a file that would be 
in my home profile.  I wan't to avoir the use of text password in my code.  
The password would be used to FTP files afterward.

Here is my sample code:
-----------------------------------
    #!E:perl\bin\perl
    use Win32::CryptData qw(:flags);
    my $test_pass =
     
pack("H*","01000000d08c9ddf0115d1118c7a00c04fc297eb01000000714b346c6eb23f49b5da499fbaa672381400000002000000000003660000a800000010000000e64dae4c0cc12c4a7027c0787022c5fc0000000004800000a000000010000000580a364225d01271e119bc7b7430f45508000000cd6f4da09c7efa7d140000009a7c306010a5b5c64f0ade887848d6f3954d6674");
   #Decrypted test password is "foobar"
    print STDERR "Crypted password is :\n" . unpack("H*",$test_pass) . 
"\n\n";
      my $DataDescr = undef ;
      my $OptionalEntropy = '11729';
      my $Reserved = undef ;
      my %PromptStruct = "";
      my $Flags = CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN | 
CRYPTPROTECT_AUDIT;
      my $DataOut="";
      my $ret = Win32::CryptData::CryptUnprotectData(\${test_pass}, 
\$DataDescr, \$OptionalEntropy, \$Reserved, \%PromptStruct, $Flags, 
\$DataOut);
      print "Password is : $DataOut and return code is: $ret\n";
      if($ret!=1){die "Probleme with password\n"}
    exit;
---------------------------------------------------------------------------------------------------------------------

After the perl script is finished I get the following error from windows:

Perl has encountered a problem and have to close. And bla.. bla... send 
message to MS ...

details are:
------------------------------------------------------------------------------------------
AppName: perl.exe        AppVer: 5.8.8.819       ModName: ntdll.dll
ModVer: 5.1.2600.2180    Offset: 00010c27
------------------------------------------------------------------------------------------

Any hints woud be welcome.

Regards,

        BT


PS:  You can't use the same crypted password on another machine but if you 
want to test,
      here is the "crypt.pl" routine I used to generate the encrypted 
password.
     It will return, in the standard output, the crypted password in text.

---------------- Crypt.pl 
---------------------------------------------------------------------------
#!E:perl\bin\perl
# Modules
      use strict;
      use Win32::CryptData qw(:flags);
### Le code
      my $DataIn = shift @ARGV || die "Text to encrypt ?";
      my $DataDescr = undef;
      my $OptionalEntropy = '11729';
      my $Reserved = undef;
      my %PromptStruct="";
      my $Flags = CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN | 
CRYPTPROTECT_AUDIT;
      my $DataOut="";
      my $ret = Win32::CryptData::CryptProtectData(\$DataIn, \$DataDescr, 
\$OptionalEntropy, \$Reserved, \%PromptStruct, $Flags, \$DataOut);

      if($ret)
      {
        print unpack("H*", $DataOut) . "\n";
      }
      else
      {
        print "Error: $^E\n";
      }
---------------------------------------------------------------


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to