EXORing Two 2-char Hex Values M5Stack UIFlow or MicroPython #10467
ashimotok0
started this conversation in
General
Replies: 2 comments
-
solutions on stackoverflow for python also valid for micropython: example:
for mote info about operators: |
Beta Was this translation helpful? Give feedback.
0 replies
-
If the result is to be a 'bytes' instance there are various ways. Here is one approach: >>> a = b'\x01\x02'
>>> b = b'\x03\x10'
>>> int.to_bytes(int.from_bytes(a, 'little') ^ int.from_bytes(b, 'little'), 2, 'little')
b'\x02\x12' Or (may be more efficient for large objects): >>> a = b'\x01\x02'
>>> b = b'\x03\x10'
>>> bytes(map(lambda x, y: x^y, a, b))
b'\x02\x12'
>>> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to EXOR Two 2-char Hex Values using M5Stack UIFlow or MicroPython. Any ideas please?
Beta Was this translation helpful? Give feedback.
All reactions