I'm getting the following error when calling the xor operator from
a .py file:
because sage interprets ^ as exponentiation, i imported the xor
function from operator.
whats even stranger, is that the xor seems to work from the command
line just fine.
--> 178 t0 = self.ideaMultiply(roundSubKeys[4],
xor(temp[0],temp[2]))
/home/abudker/Desktop/199/sage-2.5.0.2/devel/sage-main/sage/crypto/
element.pyx in element.Element.__xor__()
<type 'exceptions.RuntimeError'>: Use ** for exponentiation, not '^',
which means xor
thanks,
-Andrew Budker
sage: n = 5; m = 17
sage: n._xor(m)
20
--
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org
I should probably mention that i'm writing some crypto stuff, so the
integers im dealing with are from the python ord() function (getting
ascii values from strings). So the return type is a python long not a
sage.integer. I can go back and construct sage integer versions of
everything, but if there is another way to do it, I would greatly
prefer that.
thanks.
-Andrew
On Jun 8, 11:04 pm, "William Stein" <wst...@gmail.com> wrote:
> To avoid massive confusion the __xor__ operator is not defined for SAGE
> integers. Instead use the _xor function, which will be very fast:
>
> sage: n = 5; m = 17
> sage: n._xor(m)
> 20
>
Please post a better code snippet that illustrates what's going on?
The error message below strongly indicates that you're doing an
xor with some SAGE Elements not Python longs, so somehow your
Python ints got converted to SAGE ints. If you post a bit more code,
somebody can hopefully help. (Sorry that I misunderstood your
original question.)
-- William