http://www.perlmonks.org?node_id=141520

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

Greetings monks,

I'm looking for interesting suggestions on how to approach a problem. We have a call center which needs to provide us with a data file containing a list of people's names and addresses (along with other information). However, we're not actually allowed to look at all of the contained data, only those records that actually belong to "us". Each of the lines will be tagged with some identifier indicating "whose" data it is. For all other records, we'll need to strip them and send them out to other recipients.

For example:

ABC|John Smith|1010 Nowhere Lane ABC|George Jones|2038 Someother Road DEF|Paul Google|3827 Road to Nowhere

Now, suppose that we're "ABC". We're allowed to see all records that start with "ABC", but can't see any of the other records. The initial idea was to encrypt each record individually, but use a different key, possibly based on the recipient - so ABC records would be crypted with ABC, DEF records would be crypted with DEF, etc.

The idea is that we could go through and split the file apart without being able to understand the records. Then we send the DEF records to the DEF organization, etc. Meanwhile, we can decrypt our own ABC records using the ABC key.

Using this approach, we would get a file that contained:

ABC|<ABC-crypted John Smith|1010 Nowhere Lane> ABC|<ABC-crypted George Jones|2038 Someother Road> DEF|<DEF-crypted Paul Google|3827 Road to Nowhere>

The questions that occur to me, though, are:

  1. Does anyone have a better idea that matches the requirements? Note that the initial data file must come to us and we must not be able to easily (plain-text) read any records which do not belong to us.
  2. I don't think we need any sort of heavy-duty cryptography module for this, so does anyone have any ideas of quick-and-dirty ciphering that might work for this? (Golfing optional :-)