Greetings monks

I am transmitting data over a plain text connection and I need a way of encrypting and decrypting the data using only core perl functions since the receiving end is an embedded platform using a basic installation of perl with no modules. On top of that, crypt isn't implemented in perl :) I've tried using pack('C*', unpack('C*', $string)), but it's returning control characters for some non aZ-zZ0-9 characters on decoding (new‡7\cU\cM\cK\cK?3\cM\cKQ\cK\cW).

I saw a two line implementation of the rsa algorithm in perl but I'm looking for something more lightweight because the client only has 8 megs of ram and a small processor. I've looked at rot13 implementations in perl but to quote, 'it is not much stronger than a one meter cardboard fence'. Any thoughts? Remember, I can't use any modules.

update - a shared secret approach here would be fine, my main concern is putting some level of security in so that the data is not there for the taking.

update - thanks to perrin for the spot, Crypt::Blowfish_PP is a module with no dependencies and uses perl core functions only, I'm going to try it out on my broadcom embedded platform.

update - embedded Blowfish_PP successfully, it takes 12 seconds to construct the blowfish object but hey it works!


In reply to Encryption using perl core functions only by redhotpenguin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.