varbin / xtea Goto Github PK
View Code? Open in Web Editor NEWA python version of XTEA
A python version of XTEA
Hi,
The follow is my test code when using Xtea 0.7.1 with python3:
import xtea, struct
from binascii import hexlify
msg = b"This is a text. "
key = b' '*16
ivv = b"12345678"
tea = xtea.new(key, mode=xtea.MODE_OFB, IV=ivv)
enc = tea.encrypt(msg)
clr = tea.decrypt(enc)
print (msg == clr)
print (f' IV: {hexlify(ivv).decode()} LEN:{len(ivv)}')
print (f' KEY: {hexlify(key).decode()} LEN:{len(key)}')
print (f' MSG: {hexlify(msg).decode()} LEN:{len(msg)}')
print (f' ENC: {hexlify(enc).decode()} LEN:{len(enc)}')
print (f' CLR: {hexlify(clr).decode()} LEN:{len(clr)}')
Output when I ran it against version 0.7.1
IV: 3132333435363738 LEN:8
KEY: 20202020202020202020202020202020 LEN:16
MSG: 54686973206973206120746578742e20 LEN:16
ENC: fa66ec11b82e38bc77c14be093bb8aa0 LEN:16
CLR: 79f08adb7eab4acbb4cc1aca058c0a29 LEN:16
Test code when ran with 0.4.1 and Python2.7
import xtea, struct
from binascii import hexlify
msg = b"This is a text. "
key = b' '*16
ivv = b"12345678"
tea = xtea.new(key, mode=xtea.MODE_OFB, IV=ivv)
enc = tea.encrypt(msg)
clr = tea.decrypt(enc)
print msg == clr
print "IV: {} LEN:{}".format(hexlify(ivv).decode(),len(ivv))
print "KEY: {} LEN:{}".format(hexlify(key).decode(),len(key))
print "MSG: {} LEN:{}".format(hexlify(msg).decode(),len(msg))
print "ENC: {} LEN:{}".format(hexlify(enc).decode(),len(enc))
print "CLR: {} LEN:{}".format(hexlify(clr).decode(),len(clr))
Output:
IV: 3132333435363738 LEN:8
KEY: 20202020202020202020202020202020 LEN:16
MSG: 54686973206973206120746578742e20 LEN:16
ENC: fa66ec11b82e38bc77c14be093bb8aa0 LEN:16
CLR: 54686973206973206120746578742e20 LEN:16
Is this the right PyPi package location - https://pypi.org/project/xtea/ the version on it seems much older than the version in use on GitHub and it lacks some of the recent fixes. Is it possible to publish an update?
CBCMAC implementation is insecure because of following, fix will come soon. Try to not use it before next patch.
MAC(Message1)+MAC(Message2) = MAC(Message1+Message2)
All other implementations that I've seen define the default # of rounds to be 64, and they do 64 iterations in the encrypt. This implementation defines a round as 2 cycles, so 64 rounds = 32 iterations. This makes it not act the same as most of the other implementations of XTEA unless you set rounds=128.
Add CCM-Mode to the modes, beeing compitable for PyCrypto
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.