Skip to content

Commit

Permalink
add xtea impl
Browse files Browse the repository at this point in the history
  • Loading branch information
synodriver committed May 22, 2023
1 parent 8fe750e commit f6962a6
Show file tree
Hide file tree
Showing 15 changed files with 22,665 additions and 558 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "simple-crypto"]
path = simple-crypto
url = https://github.com/synodriver/simple-crypto
[submodule "xtea-c"]
path = xtea-c
url = https://github.com/shixiongfei/xtea
9 changes: 6 additions & 3 deletions changename.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os

for f in os.listdir('dist'):
if 'linux' in f:
os.rename(os.path.join('dist', f), os.path.join('dist', f.replace('linux', 'manylinux2014')))
for f in os.listdir("dist"):
if "linux" in f:
os.rename(
os.path.join("dist", f),
os.path.join("dist", f.replace("linux", "manylinux2014")),
)
1 change: 1 addition & 0 deletions ftea/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
Copyright (c) 2008-2021 synodriver <synodriver@gmail.com>
"""
from ftea._tea import *
from ftea._xtea import *

__version__ = "0.1.5"
1,048 changes: 537 additions & 511 deletions ftea/_tea.c

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions ftea/_tea.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ class TEA:
def decrypt(self, text: bytes, sumtable: bytes) -> bytes: ...
def decrypt_into(self, text: bytes, sumtable: bytes, out: bytearray) -> int: ...
def decrypt_native_endian(self, text: bytes, sumtable: bytes) -> bytes: ...
def decrypt_native_endian_into(self,text: bytes, sumtable: bytes, out: bytearray) -> int: ...
def decrypt_native_endian_into(
self, text: bytes, sumtable: bytes, out: bytearray
) -> int: ...
def decrypt_qq(self, text: bytes) -> bytes: ...
def decrypt_qq_into(self, text: bytes, out: bytearray) -> int: ...
def encrypt(self, text: bytes, sumtable: bytes) -> bytes: ...
def encrypt_into(self, text: bytes, sumtable: bytes, out: bytearray) -> int: ...
def encrypt_native_endian(self, text: bytes, sumtable: bytes) -> bytes: ...
def encrypt_native_endian_into(self, text: bytes, sumtable: bytes, out: bytearray) -> int: ...
def encrypt_qq(self, text: bytes) -> bytes: ...
def encrypt_native_endian_into(
self, text: bytes, sumtable: bytes, out: bytearray
) -> int: ...
def encrypt_qq(self, text: bytes) -> bytes: ...
def encrypt_qq_into(self, text: bytes, out: bytearray) -> int: ...

def encrypt_len(src: int) -> int: ...
def encrypt_len(src: int) -> int: ...
14 changes: 8 additions & 6 deletions ftea/_tea.pyx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# cython: language_level=3
from libc.stdint cimport uint8_t, uint32_t, int64_t
from libc.string cimport memcpy
cimport cython

from cpython.pycapsule cimport PyCapsule_New
from cpython.bytes cimport PyBytes_AS_STRING, PyBytes_FromStringAndSize
from cpython.object cimport PyObject
from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AS_STRING
from cpython.pycapsule cimport PyCapsule_New
from libc.stdint cimport int64_t, uint8_t, uint32_t
from libc.string cimport memcpy

from ftea.tea cimport (SHOULD_SWAP, encrypt_qq_len, swap_uint32, tea_decrypt,
tea_decrypt_native_endian, tea_decrypt_qq, tea_encrypt,
tea_encrypt_native_endian, tea_encrypt_qq)

from ftea.tea cimport tea_encrypt_qq,tea_encrypt, tea_encrypt_native_endian, tea_decrypt_qq,tea_decrypt,tea_decrypt_native_endian, encrypt_qq_len, swap_uint32, SHOULD_SWAP

@cython.freelist(8)
@cython.no_gc
Expand Down
Loading

0 comments on commit f6962a6

Please sign in to comment.