Skip to content

Commit b17e3b0

Browse files
committed
doc update
1 parent 8623449 commit b17e3b0

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ from obj_encrypt import Secret
4242
4343
4444
def main():
45-
secret = Secret(key='0123456789') # Initialize the secret instance, the key cannot exceed 32 strings.
46-
# Build the data dictionary.
45+
# Initialize the secret instance, the key is an AES-256 key, and the maximum size cannot exceed 32 strings.
46+
secret = Secret(key='0123456789')
47+
# build the data dictionary
4748
data = {
4849
'author': 'Cyberbolt',
4950
'personal_website': 'https://www.cyberlight.xyz/',
50-
'time': '2021-02-10'
51+
'time': '2022-02-10'
5152
}
5253
ciphertext = secret.encrypt(data) # Convert the object to binary ciphertext and get the ciphertext.
5354
print(ciphertext, ' ', type(ciphertext))
54-
data = secret.decrypt(ciphertext) # Decrypt ciphertext as object.
55-
print(data)
55+
plaintext = secret.decrypt(ciphertext) # Decrypt ciphertext as object.
56+
print(plaintext)
5657
5758
5859
if __name__ == '__main__':
@@ -62,8 +63,8 @@ if __name__ == '__main__':
6263
Output
6364

6465
```
65-
b'U2FsdGVkX1/WxuK0iagq5jEbJsiIGvuNZieWehVYj7i+M66y06I1WcD7gBpPKniDhIkmSuVepFdMEisT8/+HqrWHHNwoY+waDERTes+7dGHvMBc4FcuTFjMzVoQZUE0SqFMi/ORhKcpCGgSUZo/gdNBPh0nNsRZ5ZQrKbt47aw6tSOEEXHwXEr20uHjqT7wx1uvsXnGbx1l91BNhEYrAIxhaJX0YTfGOgqVgCMc9k4xxSNEoB9v19873rryT5TnTXijNeA+FRtZKN5Mt9WUFMuBYCK5xWhXKv0BJOn8iGmw=' <class 'bytes'>
66-
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2021-02-10'}
66+
b'U2FsdGVkX18IANYgINODlF8BjkxI3AaKJ/+10Iexgh65qyEKFY21HK5LSjiTuy37arjYAuIQQls+amqCdEdVdy0V1E6xECJXOFBb0kfIzQuxOimOaFFVvtq4IntjJNdCHLiTwuExVfwAW7CjqaD554B71IoT0o9xqrFch3N0vtq+UP0uXyMmMCsvu8zY7vrCuw9qM+kOW2VWsC2c2ePDnofvakchgDW9bGF8fTC3prE+TPksoJ4l6ERCjjRid54gP6+HmzB+TwOVSGaj+4VIdm1g7qv591tBU1U6Lxm83Hk=' <class 'bytes'>
67+
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2022-02-10'}
6768
```
6869

6970
In addition to Python dictionaries, you can encrypt your own objects, and the encrypted binary can be stored in a database or used for TCP communication.

README_CHN.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ from obj_encrypt import Secret
4040
4141
4242
def main():
43-
secret = Secret(key='0123456789') # 初始化 secret 实例,密钥最大不能超过 32 个字符串
43+
# 初始化 secret 实例,key 为 AES-256 密钥,最大不能超过 32 个字符串
44+
secret = Secret(key='0123456789')
4445
# 构建 data 字典
4546
data = {
4647
'author': 'Cyberbolt',
4748
'personal_website': 'https://www.cyberlight.xyz/',
48-
'time': '2021-02-10'
49+
'time': '2022-02-10'
4950
}
5051
ciphertext = secret.encrypt(data) # 将对象转为二进制密文,获取密文
5152
print(ciphertext, ' ', type(ciphertext))
52-
data = secret.decrypt(ciphertext) # 解密密文为对象
53-
print(data)
53+
plaintext = secret.decrypt(ciphertext) # 解密密文为对象
54+
print(plaintext)
5455
5556
5657
if __name__ == '__main__':
@@ -60,8 +61,8 @@ if __name__ == '__main__':
6061
输出内容
6162

6263
```
63-
b'U2FsdGVkX1/WxuK0iagq5jEbJsiIGvuNZieWehVYj7i+M66y06I1WcD7gBpPKniDhIkmSuVepFdMEisT8/+HqrWHHNwoY+waDERTes+7dGHvMBc4FcuTFjMzVoQZUE0SqFMi/ORhKcpCGgSUZo/gdNBPh0nNsRZ5ZQrKbt47aw6tSOEEXHwXEr20uHjqT7wx1uvsXnGbx1l91BNhEYrAIxhaJX0YTfGOgqVgCMc9k4xxSNEoB9v19873rryT5TnTXijNeA+FRtZKN5Mt9WUFMuBYCK5xWhXKv0BJOn8iGmw=' <class 'bytes'>
64-
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2021-02-10'}
64+
b'U2FsdGVkX18IANYgINODlF8BjkxI3AaKJ/+10Iexgh65qyEKFY21HK5LSjiTuy37arjYAuIQQls+amqCdEdVdy0V1E6xECJXOFBb0kfIzQuxOimOaFFVvtq4IntjJNdCHLiTwuExVfwAW7CjqaD554B71IoT0o9xqrFch3N0vtq+UP0uXyMmMCsvu8zY7vrCuw9qM+kOW2VWsC2c2ePDnofvakchgDW9bGF8fTC3prE+TPksoJ4l6ERCjjRid54gP6+HmzB+TwOVSGaj+4VIdm1g7qv591tBU1U6Lxm83Hk=' <class 'bytes'>
65+
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2022-02-10'}
6566
```
6667

6768
除了字典,你可以加密自己的对象,加密后的二进制可以存入数据库,也可以用于 TCP 通信。

dist/obj-encrypt-0.1.0.tar.gz

-2.83 KB
Binary file not shown.

dist/obj-encrypt-0.1.2.tar.gz

3.58 KB
Binary file not shown.
-2.95 KB
Binary file not shown.
3.84 KB
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name="obj-encrypt",
9-
version="0.1.0",
9+
version="0.1.2",
1010
author="Cyberbolt",
1111
author_email="[email protected]",
1212
description="obj-encrypt is an encryption library based on the AES-256 algorithm. It uses Python objects as the basic unit, which can convert objects into binary ciphertext and support decryption. Objects encrypted with obj-encrypt support TCP communication, database storage, and more.",

test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33

44
def main():
5-
secret = Secret(key='0123456789') # 初始化 secret 实例,密钥最大不能超过 32 个字符串
6-
# 构建 data 字典
5+
# Initialize the secret instance, the key is an AES-256 key, and the maximum size cannot exceed 32 strings.
6+
secret = Secret(key='0123456789')
7+
# build the data dictionary
78
data = {
89
'author': 'Cyberbolt',
910
'personal_website': 'https://www.cyberlight.xyz/',
10-
'time': '2021-02-10'
11+
'time': '2022-02-10'
1112
}
12-
ciphertext = secret.encrypt(data) # 将对象转为二进制密文,获取密文
13+
ciphertext = secret.encrypt(data) # Convert the object to binary ciphertext and get the ciphertext.
1314
print(ciphertext, ' ', type(ciphertext))
14-
data = secret.decrypt(ciphertext) # 解密密文为对象
15-
print(data)
15+
plaintext = secret.decrypt(ciphertext) # Decrypt ciphertext as object.
16+
print(plaintext)
1617

1718

1819
if __name__ == '__main__':

0 commit comments

Comments
 (0)