Skip to content

Commit

Permalink
Merge pull request #330 from wklken/ft_upgrade_py3_bugfix
Browse files Browse the repository at this point in the history
Ft upgrade py3 bugfix
  • Loading branch information
wklken authored May 20, 2021
2 parents 1e646a2 + a4c3341 commit b5b029a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion paas2/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.1
2.13.2
2 changes: 1 addition & 1 deletion paas2/appengine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PyYAML==5.1
uWSGI==2.0.13.1
pymysql==0.6.7
gunicorn==19.9.0
gevent==1.1.2
gevent==1.5.0
pytz==2016.6.1
six==1.15.0
python-consul==1.1.0
Expand Down
2 changes: 1 addition & 1 deletion paas2/esb/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ django==1.11.29
enum34==1.1.6
funcsigs==1.0.2; python_version >= "2.7" and python_full_version < "3.0.0" and python_version < "3.0" or python_full_version >= "3.4.0" and python_version < "3.0"
future==0.18.2; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
gevent==1.1.2
gevent==1.5.0
greenlet==1.0.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
gunicorn==19.9.0; (python_version >= "2.6" and python_full_version < "3.0.0") or (python_full_version >= "3.2.0")
idna==2.8; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
Expand Down
11 changes: 8 additions & 3 deletions paas2/login/common/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from Crypto.Cipher import AES

from django.conf import settings
from django.utils.encoding import force_bytes, force_text

"""
登录态加密方法.
Expand Down Expand Up @@ -52,14 +53,16 @@ def decrypt(ciphertext, key="", base64=True):
"""
if not key:
key = settings.SECRET_KEY
key = force_bytes(key)

if base64:
ciphertext = urlsafe_b64decode(str(ciphertext + "=" * (4 - len(ciphertext) % 4)))
# ciphertext = urlsafe_b64decode(str(ciphertext + "=" * (4 - len(ciphertext) % 4)))
ciphertext = urlsafe_b64decode(ciphertext + "=" * (4 - len(ciphertext) % 4))

data = ciphertext
key = hashlib.md5(key).digest()
cipher = AES.new(key, AES.MODE_ECB)
return unpad(cipher.decrypt(data))
return unpad(force_text(cipher.decrypt(data)))


def encrypt(plaintext, key="", base64=True):
Expand All @@ -69,13 +72,15 @@ def encrypt(plaintext, key="", base64=True):
if not key:
key = settings.SECRET_KEY

key = force_bytes(key)
key = hashlib.md5(key).digest()
cipher = AES.new(key, AES.MODE_ECB)
ciphertext = cipher.encrypt(pad(plaintext))

# 将密文base64加密
if base64:
ciphertext = urlsafe_b64encode(str(ciphertext)).rstrip("=")
# ciphertext = urlsafe_b64encode(str(ciphertext)).rstrip(b"=")
ciphertext = urlsafe_b64encode(ciphertext).rstrip(b"=")

return ciphertext

Expand Down
2 changes: 1 addition & 1 deletion paas2/login/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gunicorn==19.9.0
uWSGI==2.0.13.1
xlrd==1.0.0
xlwt==1.1.2
gevent==1.1.2
gevent==1.5.0
pytz==2016.6.1
python-dateutil==2.8.1
django_oauth_toolkit==0.12.0
Expand Down
1 change: 1 addition & 0 deletions paas2/paas/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ conf/settings_production.py
# .jshintrc
# gulpfile.js
# package.json
.envrc
2 changes: 1 addition & 1 deletion paas2/paas/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pymysql==0.6.7
redis==2.10.5
PyYAML==5.1
Pillow==6.2.2
gevent==1.1.2
gevent==1.5.0
pytz==2016.6.1
python-dateutil==2.8.1
boto==2.43.0
Expand Down
3 changes: 3 additions & 0 deletions paas2/release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Release Log
===============================
# 2.13.2
- update: bugfix for python3/upgrade gevent to 1.15.0

# 2.13.1
- update: sync with newest branch

Expand Down

0 comments on commit b5b029a

Please sign in to comment.