Re: Need XOR solution
Re: Need XOR solution
- Subject: Re: Need XOR solution
- From: "Arthur J. Knapp" <email@hidden>
- Date: Wed, 07 Aug 2002 11:27:38 -0400
>
Subject: Re: Need XOR solution
>
Date: Wed, 7 Aug 2002 09:40:05 +0100
>
From: Nigel Garvey <email@hidden>
>
You could use the brilliant "Fast ASCII" coverter from Arthur's script to
>
get the number value of each byte, and XOR them together with this:
>
on Xorify(n1, n2)
>
set xor to 0
>
repeat 8 times
>
if n1 mod 2 is not equal to n2 mod 2 then set xor to xor + 256
>
set n1 to n1 div 2
>
set n2 to n2 div 2
>
set xor to xor div 2
>
end repeat
I suspected that there was a clever "math" way to go about it, though
it eluded me.
Note: That's "eludes", not "alludes", as was pointed out to me by
Malcolm Fitzgerald:
> An allusion to oneself is a type of reference isn't it? Did you mean
> elides (delete) or eludes (unhandled) ;-)
;-)
>
This does 8-bit xor's; but it's easily adaptable to handle larger chunks.
>
...
>
set addIn to (2 ^ bits)
>
repeat bits times
>
if n1 mod 2 is not equal to n2 mod 2 then set xor to xor + addIn
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.