Hrmmmm… Seems to me that it should be the datacenter who is encrypting the file and then providing you with the means to decrypt ONLY what you should see. Right?
In which case the other answers are good.
However, since you have to trust them to be able to run and install whatever you hand them, better keep it real simple. The following might be really lame but at least it will run on most versions of perl without any effort.
After all, you did say "we must not be able to easily (plain-text) read any records which do not belong to us."
Depends on what you consider to be "easy" and "plain-text" I guess.
To encrypt and decrypt strings in an super low-security fashion:
#!/usr/bin/perl -w
use strict;
## their side before sending the file to you...
my $line = "ABC|John Smith 1234";
my ($groupID, $text) = split(/\|/, $line, 2);
$text =~ tr/a-z/f-za-e/;
$text =~ tr/A-Z/I-ZA-H/;
$text =~ tr/0-9/4-90-3/;
$line = $groupID . "\|" . $text;
print "$line\n";
## And then on your end...
my $myGroup = "ABC";
my ($group, $data) = split(/\|/, $line, 2);
if($group eq $myGroup) {
$data =~ tr/f-za-e/a-z/;
$data =~ tr/I-ZA-H/A-Z/;
$data =~ tr/4-90-3/0-9/;
}
print "$data\n";
Of course you/they would have to create different translations for each different group (perhaps trade digits with chars and uc with lc, etc.), and then provide the reverse translation to that group.
No, do not laugh… I know, I know, if someone really wanted to... They would just sit down and stare at the file for a few minutes.
Therefore, I am making the assumption that if "the datacenter" really cared they would come up with something better.
-xtype
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.