# Re: To xor or not to xor

From: Edward Cherlin <edward_dot_cherlin_at_etssg_dot_com>
Date: Sun Oct 26 2003 - 10:19:29 CST

On Friday 19 September 2003 10:45 am, Adechert@aol.com wrote:
> This sounds fine to me. I'd like to hear what others think.
>
> Alan D.
>
> In a message dated 9/19/03 6:29:24 AM Pacific Daylight Time,
> jan@it.uu.se
>
> writes:
> > I think I would like to retreat from my suggestion to use
> > XOR to obscure the bar codes. Since this involves conversion
> > between binary and decimal,

Actually, this is not the case. Although our interpretation of
the binary data is as a number in base 10, the obscuration code
deals with uninterpreted data.

> > one has to keep track of the
> > number of bits and digits, so leading zeroes are not lost
> > during the conversions. This seems unnecessary complicated
> > for this task.

Internally there is no conversion needed. One takes the data,
already stored in some binary format, and creates a bitstring of
the same length to xor it with. The length of the data segment
is not changed. A second xor restores the exact original data
bit-for-bit, no matter what kind of information is stored in it
(character, numeric, or any other). Thus there is no problem.

> > My suggestion now is instead to do a similar obscuration
> > directly on the decimal numbers.

Computers only work with bits, not with decimal numbers.

> > It is done by adding the
> > (repeated) digits in the ballot number to the digits in the
> > huge integer, modulo 10. To revert, instead subtract modulo
> > 10. For example, with ballot number 4216:
> >
> > 083076749736557242056487941267521535
> > 421642164216421642164216421642164216
> > ------------------------------------
> > 404618803942978884110693362809685741

This does require decimal arithmetic, so it does require the
computer to go through the steps needed to treat the binary
encoding of the data as a sequence of decimal numbers. If we
were to store the data as packed Binary-Coded Decimal, it would
make little difference, but if we store the data in an integer
format, your proposal requires the computer to convert back to
decimal representation. It is far more complicated than using
the computer's native binary capabilities.

Xoring is exactly the same technique as your proposal, but done
mod 2.

> > I believe the bar code would be as hard to interpret as it
> > was using the XOR method.
> >
> >
> > ------------------------------------------------------------
> >------------ import string
> >
> > def obscure(key, num):
> > keydigits = list(key)
> > numdigits = list(num)
> > for i in range(len(numdigits)):
> > numdigits[i] = str((int(numdigits[i]) +
> > int(keydigits[i % 4])) % 10)

Yes, there, in the int function, is the unnecessary conversion.

> > return string.join(numdigits, "")
> >
> > def revert(key, num):
> > keydigits = list(key)
> > numdigits = list(num)
> > for i in range(len(numdigits)):
> > numdigits[i] = str((int(numdigits[i]) -
> > int(keydigits[i % 4])) % 10)
>
> > return string.join(numdigits, "")
> >
> > ballotno = "4216"
> > barcodedata = "083076749736557242056487941267521535"
> > print barcodedata
> > obscured = obscure(ballotno, barcodedata)
> > print obscured
> > print revert(ballotno, obscured)

```--
Edward Cherlin, Simputer Evangelist
Encore Technologies (S) Pte. Ltd.
Computers for all of us
http://www.simputerland.com, http://cherlin.blogspot.com
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
```
Received on Fri Oct 31 23:17:04 2003

This archive was generated by hypermail 2.1.8 : Fri Oct 31 2003 - 23:17:07 CST