in reply to Win32::API and ::Prototype assistance

Some potentially working code :

#!perl #use strict; use Win32::API::Prototype; ApiLink( 'eq_handy.dll', 'BOOL bgfnTextDecrypt( LPSTR lpString, LPSTR +, lpBuffer )' ) || die ($!); my $passphrase="encrypt-phrase"; my $lpString = pack( "L2", $passphrase,0); print "Hi there\n"; $nBufferLength = 256; $lpBuffer = NewString( $nBufferLength ); if (bgfnTextDecrypt($lpString,$lpBuffer, $nBufferLength)) { print "It worked!\n"; } my $pass = unpack( "L*", $lpBuffer ); print "The pass is:",$pass,"\n";
Output is:
Hi there It worked! The pass is:189
The actual pass is bluemean.
I think my unpack is wrong.. any suggestions?
Neil

Replies are listed 'Best First'.
Re^2: Win32::API and ::Prototype assistance - Victory
by neilh (Pilgrim) on Jul 29, 2005 at 12:42 UTC
    Well I got it to work. It turned out that my pack and unpack were wrong.
    Thanks to the Pack/Unpack Tutorial (aka How the System Stores Data) for the ideas.

    #!perl use strict; use Win32::API::Prototype; ApiLink( 'eq_handy.dll', 'BOOL bgfnTextDecrypt( LPTSTR lpString, LPTS +TR, lpBuffer )' ) || die ($!); my $passphrase="encrypt-pass"; my $lpString = pack( "A*", $passphrase,0); print "Hi there\n"; my $nBufferLength = 256; my $lpBuffer = NewString( $nBufferLength ); if (bgfnTextDecrypt($lpString,$lpBuffer, $nBufferLength)) { print "It worked!\n"; } my $pass = unpack( "A*", $lpBuffer ); print "The pass is:",$pass,"\n";
    Back to my box.

    Neil