Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
welliamcao committed Apr 25, 2020
1 parent 2021d42 commit 6e63595
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions utils/secret/aescipher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
# _#_ coding:utf-8 _*_
# 参考https://pypi.org/project/obscure-api/

import base64
import hashlib

Expand Down Expand Up @@ -29,32 +31,3 @@ def _pad(self, s):
@staticmethod
def _unpad(s):
return s[:-ord(s[len(s)-1:])]


# BS = 16
#
#
# def pad(s):
# return s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
#
#
# def unpad(s):
# return s[0:-s[-1]]
#
#
# class AESCipher:
#
# def __init__(self, key):
# self.key = hashlib.sha256(key.encode('utf-8')).digest()
#
# def encrypt(self, raw):
# raw = pad(raw)
# iv = Random.new().read(AES.block_size)
# cipher = AES.new(self.key, AES.MODE_CBC, iv)
# return base64.b64encode(iv + cipher.encrypt(raw))
#
# def decrypt(self, enc):
# enc = base64.b64decode(enc)
# iv = enc[:16]
# cipher = AES.new(self.key, AES.MODE_CBC, iv)
# return unpad(cipher.decrypt(enc[16:]))

0 comments on commit 6e63595

Please sign in to comment.