Giter VIP home page Giter VIP logo

Comments (5)

theStack avatar theStack commented on July 18, 2024

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 methods encrypt and decrypt 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 by int in function stringToLong (long doesn't exist anymore in Python 3)
  • replacing types.IntType, types.LongType, types.FloatType with int, int, float, respectively

from xtea.

Varbin avatar Varbin commented on July 18, 2024

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.

Varbin avatar Varbin commented on July 18, 2024

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 and b_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.

chrisrossi avatar chrisrossi commented on July 18, 2024

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.

Varbin avatar Varbin commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.