Date: Thu, 21 Feb 2002 10:42:39 -0800
Reply-To: Cassell.David@EPAMAIL.EPA.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "David L. Cassell" <Cassell.David@EPAMAIL.EPA.GOV>
Subject: Re: Encrypting a field in the SAS file!
Content-type: text/plain; charset=us-ascii
Stig Eide <stigeide@YAHOO.COM> wrote:
> I don't understand how you can use BXOR() to encrypt a string?
> Bxor needs two numerical arguments?
>Could you please provide me with an example?
and Rashida Patwa wrote in private e-mail [in part]:
> Do you have an example of such array??
Well, I guess I was spectacularly unclear in my previous message.
So let me give a trivial example of what I had in mind. Microsoft
has used XOR as a weak cryptographic tool [just look up your screen
saver password's transformed version on your system, and you'll see
it is your actual password XOR'ed to hide it from only the most naive
observers], and that's what I was thinking of. Stig is right [of
course], but that's what rank() and byte() are for. So look at this
code:
data temp1;
input string1 $char12.;
datalines;
123456789012
XXX-XX-XXXX
X23J47HIKE!!
;
run;
data temp2;
length newstring $ 12;
drop _i_;
array secret {12} $ _temporary_ ('B','i','l','l','G','a','t','e','s',
'I','s','A');
/* Complete this sentence yourself! */
array alter {12} $ _temporary_;
set temp1;
do _i_=1 to 12; /* Paul would have used _iorc_ here :-) */
alter{_i_} = substr(string1,_i_,1);
alter{_i_} = byte( bxor( rank(alter{_i_}), rank(secret{_i_}) ) );
/* put alter{_i_}=hex.; */
/* uncomment this to see how the data are actually stored and
transformed */
substr(newstring,_i_,1) = alter{_i_};
end;
run;
proc print data=temp2; run;
Perhaps this explains a little better. It is clearly not perfect. I
chose
some XORs which yield non-printing characters. But this is really not
the
way to do encryption anyway, so I'm not that concerned about its
utility.
David
--
David Cassell, CSC
Cassell.David@epa.gov
Senior computing specialist
mathematical statistician
|