boat73 has asked for the wisdom of the Perl Monks concerning the following question:

I have written a simple script that encrypts "This is a test" and prints the encrypted data to the screen. This script works as expected when running it as a perl script but not when I convert it to and exe. When I run the exe it hangs and pegs the cpu. I have tried converting it using the following methods.
PDK(perlapp)
perl2exe
PAR
p2e.pl(app::packer)

I have used all of these methods before (mostly use PDK now) and have never run into this before. I was hoping somebody has run across this issue before. As always I will greatly appreciate any help that is offered. Below is the code I am converting.
use Crypt::OpenPGP; $pgp = Crypt::OpenPGP->new ( "PubRing" => 'pubring.pkr' )or die Crypt::OpenPGP->errstr; my $ciphertext = $pgp->encrypt ( "Data" => 'This is a test', "Recipients" => 'myemail\@blah.com', "Cipher" => 'DES3', "Armour" => 1 ); die "Encryption failed: ", $pgp->errstr unless $ciphertext; print $ciphertext;
Thanks, Garett

Replies are listed 'Best First'.
Re: Problems creating Crypt::OpenPGP standalone exe
by arden (Curate) on Mar 22, 2004 at 05:12 UTC
    boat73, I'm not sure about the others, but I've seen that ActiveState has stated that Crypt::OpenPGP fails all tests. From what I can tell though, it's because the test suite didn't bother to create the basic key files and location files. This might be why perlapp won't work.

    Since you're doing this on Windows, which version of Perl are you using (ActiveState or cygwin and which build)? If you try to run the executable from the same directory as where the script version works, does it work there? Have you tried inserting some debugging print statements between each step of your program to see where the compiled version hangs? My guess is that the compiled version can't find some file which the scripted version can. . .

    - - arden.

      I've seen that ActiveState has stated that Crypt::OpenPGP fails all tests. From what I can tell though, it's because the test suite didn't bother to create the basic key files and location files.
      I wouldn't rely on ActiveState's automated ppm buildstatus. All tests pass for me.
      Since you're doing this on Windows, which version of Perl are you using (ActiveState or cygwin and which build)?
      cygwin runs on windows but cygwin is not windows. When somebody says they're running perl on windows cygwin is not involved (its probably activeperl or at least activeperl flavored perl, never cygwin).

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Problems creating Crypt::OpenPGP standalone exe
by PodMaster (Abbot) on Mar 22, 2004 at 10:17 UTC
    This is a typical issue (it's probably faq somewhere), and is one of missing dependencies. Add
    END { my @pp = 'pp', '-n'; foreach(keys %INC){ s[/][::]g; s/\.pm$//; push @pp, '-M', $_; } push @pp, __FILE__; print "@pp $/"; }
    and run the resulting command. For me that was
    pp -M Crypt::OpenPGP::Plaintext -M Carp -M Crypt::OpenPGP::Buffer -M C +rypt::Random::Generator -M lib -M Crypt::OpenPGP::Util -M IO::Socket: +:UNIX -M Crypt::OpenPGP::Signature::SubPacket -M Crypt::OpenPGP::Key: +:Public::DSA -M constant -M Convert::ASCII::Armour -M IO::Socket::INE +T -M Crypt::DES -M strict -M Crypt::OpenPGP::Key -M vars -M base -M C +onfig -M Crypt::RSA::DataFormat -M Crypt::CBC -M Digest::SHA1 -M Cryp +t::Random::Provider::devurandom -M Crypt::RSA::Key::Public -M Data::D +umper -M Crypt::OpenPGP::Certificate -M Crypt::OpenPGP::Key::Public - +M Crypt::RSA -M Crypt::OpenPGP::Key::Public::RSA -M Crypt::DSA::Key - +M MIME::Base64 -M Symbol -M Exporter::Heavy -M Crypt::OpenPGP::Signat +ure -M bytes -M C:::Perl::site::lib::auto::Compress::Zlib::autosplit. +ix -M Crypt::OpenPGP::Ciphertext -M Crypt::OpenPGP::PacketFactory -M +Crypt::RSA::Errorhandler -M Crypt::Random::Provider::egd -M IO::Handl +e -M Crypt::OpenPGP::Key::Secret -M Crypt::OpenPGP -M Crypt::OpenPGP: +:ErrorHandler -M Crypt::OpenPGP::Config -M Math::Pari -M Crypt::OpenP +GP::Key::Public::ElGamal -M Crypt::OpenPGP::KeyRing -M Exporter -M IO +::Socket -M Errno -M Crypt::OpenPGP::Digest -M subs -M DynaLoader -M +File::Spec::Unix -M Crypt::Random -M Crypt::Random::Provider::rand -M + Crypt::RSA::Key::Private -M SelectSaver -M Crypt::OpenPGP::S2k -M IO + -M Crypt::OpenPGP::Message -M File::Spec::Win32 -M Class::Loader -M +Socket -M Crypt::OpenPGP::KeyBlock -M Crypt::OpenPGP::SessionKey -M C +rypt::OpenPGP::Armour -M integer -M Compress::Zlib -M XSLoader -M Dig +est::MD5 -M Crypt::DES_EDE3 -M Crypt::OpenPGP::CFB -M Crypt::OpenPGP: +:Constants -M Tie::EncryptedHash -M File::Spec -M Crypt::RSA::Key -M +warnings::register -M warnings -M Crypt::Primes -M Crypt::OpenPGP::Us +erID -M overload -M Crypt::DSA::Util -M Crypt::OpenPGP::Cipher -M Aut +oLoader -M Crypt::Random::Provider::File -M Data::Buffer test.pl
    The resulting file was 2.09 MB (2,198,289 bytes) in size.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      I had all but given up hope. I can't thank you enough. Works great!!!! Any sugguestions on controlling how much CPU the process can take?
        Why with use less 'CPU'; of course. Seeing how that's currently unimplemented (but it could be windows -- hmm, this should be a wishlist item for PAR), you'll have to do it like
        cat foowithlesscpu.bat cmd.exe /c start /LOW foo.exe
        or write it in perl with Win32::Process.

        I should note that it should only be CPU intensive only on the 1st run when par has to extract all the modules ... after that they're cached (then it's as cpu intensive as it takes encode the message).

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.