----- Original Message ----- 
From: "Bernard Tremblay"
.
.
>
> Here is my sample code:
> -----------------------------------
>     #!E:perl\bin\perl
>     use Win32::CryptData qw(:flags);
>     my $test_pass =
>
>
pack("H*","01000000d08c9ddf0115d1118c7a00c04fc297eb01000000714b346c6eb23f49b
5da499fbaa672381400000002000000000003660000a800000010000000e64dae4c0cc12c4a7
027c0787022c5fc0000000004800000a000000010000000580a364225d01271e119bc7b7430f
45508000000cd6f4da09c7efa7d140000009a7c306010a5b5c64f0ade887848d6f3954d6674"
);

That doesn't seem to be the full string (or is it just that I'm on a
different machine ?). By my reckoning it should be:

pack("H*","01000000d08c9ddf0115d1118c7a00c04fc297eb010000000c29296fe97c0d428
e9c60b68a76aa8d04000000ae01000000554e4b4e4f574e005f5f414e4f4e5f5f00524546005
343414c4152004c56414c5545004152524159004841534800434f444500474c4f4200464f524
d415400494f00d6e50810d6e50810d6e50810d6e50810d6e50810d6e50810d6e50810d6e5081
0d6e50810ebe508101de6081025e608102de6081035e608103de6081045e6081070616e69633
a2064656c5f6261636b726566000044455354524f592063726561746564206e6577207265666
572656e636520746f2064656164206f626a65637420272573270070616e69633a20504f50535
441434b0a00002cef08102cef081010ef081010ef081010ef081010ef0810e5ee081027f0081
013f00810cbef0810dfef0810cbef081068ef0810a0ee08107fee0810b8f10810c9f10810daf
10810ebf10810cdf00810def00810eff008100af1081025f1081040f108105bf1081076f1081
03bf008103bf00810417474656d707420746f206672656520756e7265666572656e636564207
363616c61723a205356203078256c782c205065726c20696e7465727072657465723a2030782
5700043616e2774207570677261646520746f20756e64656600000003660000a800000010000
000cdb04657e819db6a7675ac2cd6c0deca0000000004800000a000000010000000853528396
804c87e09e08cb3b6b7b37608000000e3d95f27cace234e140000000b921e3e5a723fb0981e2
ff83a93ff00ef8cf3ab");

>    #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 = "";

Instead:
         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"}

It could be useful to see what $^E has been set to:
      if($ret!=1){die "Probleme with password: $^E\n"}

>     exit;
> --------------------------------------------------------------------------
-------------------------------------------
>

With the above changes in place, the program runs fine for me, finishing up
with:

Password is : foobar and return code is: 1

I'm on Windows 2000, perl 5.8.8, Win32::API-0.41 and Win32::CryptData-0.02.

Cheers,
Rob

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

Reply via email to