snacktime wrote:
I need to calculate the lrc of a string using an exclusive or on each
byte in the string.  How would I do this in python?

lrc == Linear Redundancy Check? or Longitudinal? Note that such terms are not precisely defined... generally just acronyms people make up and stick in their user manuals for stuff. :-)

import operator
lrc = reduce(operator.xor, [ord(c) for c in string])

Note that this returns an integer, so if you plan
to send this as a byte or compare it to a character
received, use chr(lrc) on it first.

-Peter

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to