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

Hi,

I need to encrypt some things in perl that I can then decrypt in C.

I'm having a hard time determining which module/encryption scheme(s) use a standard, or the same algorithm in C so I can be sure I can decrypt.

I'd prefer something simpler, that doesnt' require me to link in some huge library to my C programs, to merely get the decryption algorithm in.

Any suggestions ;/ ?

thank you!

taiko

  • Comment on Perl module for language portable encryption

Replies are listed 'Best First'.
Re: Perl module for language portable encryption
by hardburn (Abbot) on Apr 21, 2005 at 14:25 UTC

    Pretty much anything under the Crypt:: namespace will work. In fact, most of them are just Perl interfaces on top of a C library. As long as you use the same algorithm (AES is a good choice) and the same encryption mode (use CBC unless you have a specific reason not to), there's no reason you can't decrypt on the C side of things.

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      thanks!

      Hmm I'd love to use Crypt::CBC, or Crypt::* whatever, but looking at the source code, so far I don't really see them utilizing any of the underlying C functions, looks perl impelmented.

      I'll keep digging through some of these, I may be missing it.

        An algorithm is language agnostic. That is to say that any encryption algorithm should operate the same regardless of wheter it was implemented in Perl, C, COBOL, Fortran, Lisp, etc... So, let's say that you choose DES. There's a DES module for Perl, and I'm sure with a bit of searching, you can find a C implementation of it. You can write your respective programs around those two libraries; your Perl program around the Perl module, and the C program around the C library. Easy, peasy, Japanese-y.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come

Re: Perl module for language portable encryption
by zentara (Cardinal) on Apr 22, 2005 at 12:18 UTC
    If you want something simpler, look at rc4. There are alot of rc4.c code examples out there, just google for "rc4 c". There is a Crypt::RC4 module, and you might want to look at it's perldoc.

    I think your biggest problem will be making sure the keys are the same. Many encryption algorithms pad the keys to be a certain length, and you will need to make sure you do it the same in c and perl, or it won't work.


    I'm not really a human, but I play one on earth. flash japh
A reply falls below the community's threshold of quality. You may see it by logging in.