Comments (5)
Is development of xtea3 still active?
I've looked into the module trying to make it Python 3 compatible, the following steps were needed:
- remove the 'L' suffix from constants in methods
_encrypt
and_decrypt
, as this is not valid in Python 3 anymore (not sure though if it hurts if missing in Python 2.x) - replace all '/' operators with '//' (floor division, available since Python 2.2)
- put parantheses around ordinary print statements
- rewrite print statements directing output to stderr (e.g. sys.stderr.write("foobar\n") which both works in Python 2 and 3)
- define a dummy function for ord() just returning the passed value if we use Python 3, e.g.:
if sys.version_info.major >= 3: def ord(c): return c
- use
b"".join(...)
instead of"".join(...)
in methodsencrypt
anddecrypt
to create byte strings - let both functions
xor_strings
and_crypt_ofb
return a byte string rather than a string by applying.encode("latin-1")
to the return value (this unfortunately breaks compatibility with Python 2) - replace
long
byint
in functionstringToLong
(long doesn't exist anymore in Python 3) - replacing
types.IntType, types.LongType, types.FloatType
withint, int, float
, respectively
from xtea.
xtea3 is even working (https://github.com/Varbin/xtea3) but not working with python 3 python 2.
But I think it's better to have one codebase for both, too.
By the way: Why does .encode("latin-1")
break compatibility in Python2? In Python 2 the function will return a string ( an encoded string is still a string) and on Python 3 it should return bytes.
Latin-1 seems to be ASCII in python 2...
from xtea.
Thank you for your contribution, I added many of your ideas to the code.
I made following changes to your steps:
- Instead of using dummy ord, I defined
b_ord
andb_chr
. - xor_strings behaves different on python 2 and python 3
- import from
__future__
for the print function in python 2 and 3 - The test function will raise an exception if there is an error, so no need to write to stderr
- The code for
types.IntType, etc.
is not needed anymore
from xtea.
Any possibility of a release to get Python 3 support? Tests seem to work on master in Python 2 and Python 3. If there's a blocking issue, maybe I can help. Let me know.
from xtea.
The current master is fully working under Python 3 (and 2). But thanks @chrisrossi . A release will be released in the next few days.
from xtea.
Related Issues (9)
- CBCMAC implementation HOT 1
- CCM-Mode HOT 2
- ECB-mode not as default anymore
- Why is rounds divided by 2? HOT 2
- Counter module is not correctly installed.
- XTea on PyPi seems to have not been updated HOT 2
- Bug in the decrypt() of version 0.7.1 but not in 0.4.1 HOT 3
- Getting 'False' after running example in __init___.py code HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xtea.