A possible alternative depends on whether you actually need to decrypt the data or not.

You might be able to use a one-way function.

For example, the traditional unix password mechanism takes your password and runs it through the crypt() function (with a little salt) to get an output string which is stored in the /etc/passwd file.

What it *doesn't* do when you try to log in is decrypt the stored password and compare it to what you just typed. Instead, it passes what you just typed through the same one-way function (with the same salt) and compares the outputs.

The theory is that it is computationally expensive to recover the input to the one-way function. In practice, the traditional unix scheme using the crypt() function can be brute-forced fairly easily these days (for example by trying all possible or all likely combinations of inputs), but other hash functions (for example MD5) exist and are good for todays use. (A relevant perl module here is Digest::MD5).

If you really need to recover the data (rather than compare it to some other data) then you can't do this, but obviously any program you write which is able to recover the encrypted data can be used by anyone else who acquires the privilege to execute it (or read its data files containing the key information).

As I'm sure you are aware, the whole area of encryption etc is fraught with seemingly-good ideas which don't help at all or are actually counter-productive, so it is difficult to offer detailed helpful advice.

Good luck.


In reply to Re: Encryption and decryption using different keys by jbert
in thread Encryption and decryption using different keys by fx

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.