From 92d8a5a78cb88d8cb85c107f6b9a2857b6715c92 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Mon, 11 Jan 2016 23:41:50 +0800 Subject: [PATCH 1/9] 2016 --- xxtea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xxtea.c b/xxtea.c index e3425f3..3fb7ed3 100644 --- a/xxtea.c +++ b/xxtea.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015, Yue Du + * Copyright (c) 2014-2016, Yue Du * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, From f67ea5bea5122b322e4edc1a214e16b0bbf40b08 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 11:56:22 +0800 Subject: [PATCH 2/9] ALLOW_THREADS --- xxtea.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xxtea.c b/xxtea.c index 3fb7ed3..dd7f3dd 100644 --- a/xxtea.c +++ b/xxtea.c @@ -210,9 +210,11 @@ static PyObject *xxtea_encrypt(PyObject *self, PyObject *args, PyObject *kwargs) return PyErr_NoMemory(); } + Py_BEGIN_ALLOW_THREADS bytes2longs(data, dlen, d, 1); bytes2longs(key, klen, k, 0); btea(d, alen, k); + Py_END_ALLOW_THREADS retval = PyString_FromStringAndSize(NULL, (alen << 2)); @@ -302,11 +304,13 @@ static PyObject *xxtea_decrypt(PyObject *self, PyObject *args, PyObject *kwargs) } + Py_BEGIN_ALLOW_THREADS bytes2longs(data, dlen, d, 0); bytes2longs(key, klen, k, 0); btea(d, -alen, k); - rc = longs2bytes(d, alen, retbuf, 1); + Py_END_ALLOW_THREADS + if (rc >= 0) { /* Remove PKCS#7 padded chars */ Py_SIZE(retval) = rc; From bc64809e0ddcff545f16a7d861d97e4871c350af Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:07:14 +0800 Subject: [PATCH 3/9] Add AppVeyor CI --- README.rst | 4 ++++ appveyor.yml | 35 +++++++++++++++++++++++++++++++++++ xxtea.c | 17 ++++++++--------- 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 appveyor.yml diff --git a/README.rst b/README.rst index 47a5e49..766aad3 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,10 @@ xxtea |travis-badge| |pypi-badge| .. |travis-badge| image:: https://travis-ci.org/ifduyue/xxtea.png :target: https://travis-ci.org/ifduyue/xxtea +.. image:: https://ci.appveyor.com/api/projects/status/mitcnsayvbr10gt4?svg=true + :target: https://ci.appveyor.com/project/duyue/xxtea + :alt: Appveyor Build Status + .. |pypi-badge| image:: https://badge.fury.io/py/xxtea.svg :target: http://badge.fury.io/py/xxtea diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..dc95cc9 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +environment: + matrix: + - PYTHON: "C:\\Python26" + - PYTHON: "C:\\Python26-x64" + - PYTHON: "C:\\Python27" + - PYTHON: "C:\\Python27-x64" + - PYTHON: "C:\\Python33" + - PYTHON: "C:\\Python33-x64" + - PYTHON: "C:\\Python34" + - PYTHON: "C:\\Python34-x64" + - PYTHON: "C:\\Python35" + - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python36" + - PYTHON: "C:\\Python36-x64" + +build: off + +install: + - git --version + - python --version + - pip install --disable-pip-version-check --user --upgrade pip + - pip install --upgrade wheel setuptools + - pip --version + +test_script: + - python setup.py test + +after_test: + - python setup.py bdist_wheel + - python setup.py bdist_wininst + - python setup.py bdist_msi + - ps: ls dist + +artifacts: + - path: dist\* diff --git a/xxtea.c b/xxtea.c index dd7f3dd..f2485bd 100644 --- a/xxtea.c +++ b/xxtea.c @@ -26,7 +26,6 @@ #include -#include #include #include @@ -53,9 +52,9 @@ static PyObject *_xxtea_pyunicode_unhexlify; static PyObject *_xxtea_pyunicode_decrypt; -static void btea(uint32_t *v, int n, uint32_t const key[4]) +static void btea(unsigned int *v, int n, unsigned int const key[4]) { - uint32_t y, z, sum; + unsigned int y, z, sum; unsigned p, rounds, e; if (n > 1) { /* Coding Part */ @@ -99,7 +98,7 @@ static void btea(uint32_t *v, int n, uint32_t const key[4]) } } -static int bytes2longs(const char *in, int inlen, uint32_t *out, int padding) +static int bytes2longs(const char *in, int inlen, unsigned int *out, int padding) { int i, pad; const unsigned char *s; @@ -127,7 +126,7 @@ static int bytes2longs(const char *in, int inlen, uint32_t *out, int padding) return ((i - 1) >> 2) + 1; } -static int longs2bytes(uint32_t *in, int inlen, char *out, int padding) +static int longs2bytes(unsigned int *in, int inlen, char *out, int padding) { int i, outlen, pad; unsigned char *s; @@ -188,7 +187,7 @@ static PyObject *xxtea_encrypt(PyObject *self, PyObject *args, PyObject *kwargs) int alen, dlen, klen; PyObject *retval; char *retbuf; - uint32_t *d, k[4]; + unsigned int *d, k[4]; d = NULL; retval = NULL; @@ -204,7 +203,7 @@ static PyObject *xxtea_encrypt(PyObject *self, PyObject *args, PyObject *kwargs) } alen = dlen < 4 ? 2 : (dlen >> 2) + 1; - d = (uint32_t *)calloc(alen, sizeof(uint32_t)); + d = (unsigned int *)calloc(alen, sizeof(unsigned int)); if (d == NULL) { return PyErr_NoMemory(); @@ -266,7 +265,7 @@ static PyObject *xxtea_decrypt(PyObject *self, PyObject *args, PyObject *kwargs) int alen, dlen, klen, rc; PyObject *retval; char *retbuf; - uint32_t *d, k[4]; + unsigned int *d, k[4]; d = NULL; retval = NULL; @@ -296,7 +295,7 @@ static PyObject *xxtea_decrypt(PyObject *self, PyObject *args, PyObject *kwargs) } alen = dlen / 4; - d = (uint32_t *)calloc(alen, sizeof(uint32_t)); + d = (unsigned int *)calloc(alen, sizeof(unsigned int)); if (d == NULL) { PyErr_NoMemory(); From c0b1dc4f7fd40824a1dc7960c5d1e22304c4511a Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:25:55 +0800 Subject: [PATCH 4/9] Update badges --- README.rst | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index 766aad3..ec5d94d 100644 --- a/README.rst +++ b/README.rst @@ -1,15 +1,24 @@ -xxtea |travis-badge| |pypi-badge| -================================== +xxtea |travis-badge| |appveyor-badge| |pypi-badge| |supported-pythons-badge| |license-badge| +============================================================================================== -.. |travis-badge| image:: https://travis-ci.org/ifduyue/xxtea.png - :target: https://travis-ci.org/ifduyue/xxtea +.. |travis-badge| image:: https://travis-ci.org/ifduyue/xxtea.svg + :target: https://travis-ci.org/ifduyue/xxtea -.. image:: https://ci.appveyor.com/api/projects/status/mitcnsayvbr10gt4?svg=true - :target: https://ci.appveyor.com/project/duyue/xxtea - :alt: Appveyor Build Status +.. |appveyor-badge| image:: https://ci.appveyor.com/api/projects/status/mitcnsayvbr10gt4?svg=true + :target: https://ci.appveyor.com/project/duyue/xxtea + :alt: Appveyor Build Status -.. |pypi-badge| image:: https://badge.fury.io/py/xxtea.svg - :target: http://badge.fury.io/py/xxtea +.. |pypi-badge| image:: https://img.shields.io/pypi/v/xxtea.svg + :target: https://pypi.python.org/pypi/xxtea + :alt: Latest Version + +.. |supported-pythons-badge| image:: https://img.shields.io/pypi/pyversions/xxtea.svg + :target: https://pypi.python.org/pypi/xxtea + :alt: Supported Python versions + +.. |license-badge| image:: https://img.shields.io/pypi/l/xxtea.svg + :target: https://pypi.python.org/pypi/xxtea + :alt: License .. _XXTEA: http://en.wikipedia.org/wiki/XXTEA .. _longs2bytes: https://github.com/ifduyue/xxtea/blob/master/xxtea.c#L130 From 390ceb6f14eb11d78639ccf2a1393930b3bee52c Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:27:00 +0800 Subject: [PATCH 5/9] Add Programming Language :: Python :: 3.6 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b4d90a0..f168ea7 100644 --- a/setup.py +++ b/setup.py @@ -49,6 +49,7 @@ 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', ], setup_requires=["nose>=1.3.0"], test_suite='nose.collector', From 76ded0d83fc8c7314f9007ee52c5b70c09994e20 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:30:57 +0800 Subject: [PATCH 6/9] Add travis python 3.6 env --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 71def4b..651ac89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ python: - 3.3 - 3.4 - 3.5 + - 3.6 install: - gcc --version script: python setup.py test From f76fb231cfc95478e8280308758173c6b6b10f8c Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:31:10 +0800 Subject: [PATCH 7/9] Add appveyor python 3.2 env --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index dc95cc9..ca98151 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ environment: - PYTHON: "C:\\Python26-x64" - PYTHON: "C:\\Python27" - PYTHON: "C:\\Python27-x64" + - PYTHON: "C:\\Python32" + - PYTHON: "C:\\Python32-x64" - PYTHON: "C:\\Python33" - PYTHON: "C:\\Python33-x64" - PYTHON: "C:\\Python34" From fd61c81cd9115bb351a0a3e7eee115e503375d97 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sat, 25 Mar 2017 20:38:22 +0800 Subject: [PATCH 8/9] Add travis 3.7-dev and pypy env --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 651ac89..78a1817 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ python: - 3.4 - 3.5 - 3.6 + - 3.7-dev + - pypy install: - gcc --version script: python setup.py test From c821f332cb27ddd3be80ad673e240ccfa69314a3 Mon Sep 17 00:00:00 2001 From: Yue Du Date: Sun, 26 Mar 2017 16:03:08 +0800 Subject: [PATCH 9/9] v1.1.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f168ea7..5d1f6a0 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup, Extension import os -VERSION = "1.0.2" +VERSION = "1.1.0" if os.name == 'posix': extra_compile_args = [