use strict; use Win32::CryptData qw(:flags); my $DataIn = ''; my $DataDescr = 'This is the description'; my $OptionalEntropy = 'mysecret'; my $Reserved = undef; my %PromptStruct = ( PromptFlags => CRYPTPROTECT_PROMPT_ON_PROTECT | CRYPTPROTECT_PROMPT_ON_UNPROTECT | CRYPTPROTECT_PROMPT_STRONG, hwndApp => undef, Prompt => 'This is the caption' ); my $Flags = CRYPTPROTECT_AUDIT; my $DataOut; my $ret = Win32::CryptData::CryptProtectData( \$DataIn, \$DataDescr, \$OptionalEntropy, \$Reserved, \%PromptStruct, $Flags, \$DataOut ); if ($ret) { print "Encrypted data (hex): " . unpack( "H*", $DataOut ) . "\n"; } else { print "Error: $^E\n"; }