bcmd 0.0.63__py3-none-any.whl → 0.0.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bcmd might be problematic. Click here for more details.
- bcmd/common/password.py +4 -4
- bcmd/main.py +1 -1
- bcmd/tasks/__init__.py +1 -0
- bcmd/tasks/crypto.py +117 -0
- {bcmd-0.0.63.dist-info → bcmd-0.0.64.dist-info}/METADATA +2 -2
- {bcmd-0.0.63.dist-info → bcmd-0.0.64.dist-info}/RECORD +9 -8
- {bcmd-0.0.63.dist-info → bcmd-0.0.64.dist-info}/WHEEL +0 -0
- {bcmd-0.0.63.dist-info → bcmd-0.0.64.dist-info}/entry_points.txt +0 -0
- {bcmd-0.0.63.dist-info → bcmd-0.0.64.dist-info}/top_level.txt +0 -0
bcmd/common/password.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import getpass
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
|
-
from beni import bcache,
|
|
4
|
+
from beni import bcache, bcrypto
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
@bcache.cache
|
|
8
8
|
async def getPypi() -> tuple[str, str]:
|
|
9
|
-
content = 'pypi.org
|
|
9
|
+
content = 'pypi.org gAABl0ruN3xd3bOT6kGy-Zpb8liT7Qzan7jC3c9nR7mvmoaC3QVJuWl11-9vArCK8AQq_ML5_ghAnW7i2tSQ00W2DITy_eYzwaKLPHz42KSLp5vPkOOmAIWDSBIzVYizDgE1wkDL8TxAGjRvS4nWD1LVAgEC5PSrck4uLw5dDrfa-z_C0WZYaHLMLdmDQ0d060ac7bb8fc523AAAvPXGB2B8ZMT6qnk08ExNYHuYDwCxixIv1FEBRPEEV7q_cCZpYvplscWh1oUKDDFy1gqH0jjvFn7-Fai2y4MGO9Wz081CglHkT66H8MdHa027rc-vdvS-Guk2pIXgExlwtiAFHjQVJLler5pbOk-obuLRIxNqs5ibRuaymMQ4NLZI8G6mH5-NB3M=4058304a696d7f92c'
|
|
10
10
|
data = _getData(content)
|
|
11
11
|
return data['username'], data['password']
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@bcache.cache
|
|
15
15
|
async def getQiniu() -> tuple[str, str]:
|
|
16
|
-
content = '七牛云
|
|
16
|
+
content = '七牛云 gAABl0RjrmaAQv8ByatIWP0du5igDBP_28GffENjKvw9KQI1lGGeweOO_T01OL-LBUPlJ8SXIOPIv1obubke8Zv_JzyLpBkpVhpJLusDxbcLSUjjT0ce3f1b4f89fd698A3AAvQBXU8UuPUw2FrBKx2EVVhtWim2Oj_pI_B4QD6K-IP9_kHWixTenckI_Lcnw4KPSJIDRmCmtSb4RS45cVLlc4Umd4UT4smTYYlH34BA2RSEbQ==63b3af29f373954f0'
|
|
17
17
|
data = _getData(content)
|
|
18
18
|
return data['ak'], data['sk']
|
|
19
19
|
|
|
@@ -27,7 +27,7 @@ def _getData(content: str) -> dict[str, Any]:
|
|
|
27
27
|
while True:
|
|
28
28
|
try:
|
|
29
29
|
pwd = getpass.getpass(tips)
|
|
30
|
-
return
|
|
30
|
+
return bcrypto.decryptJson(content.encode(), pwd)
|
|
31
31
|
except KeyboardInterrupt:
|
|
32
32
|
raise Exception('操作取消')
|
|
33
33
|
except BaseException:
|
bcmd/main.py
CHANGED
bcmd/tasks/__init__.py
CHANGED
bcmd/tasks/crypto.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import getpass
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Final
|
|
5
|
+
|
|
6
|
+
import pyperclip
|
|
7
|
+
import typer
|
|
8
|
+
from beni import bcolor, bcrypto, bfile, btask
|
|
9
|
+
from beni.bfunc import syncCall
|
|
10
|
+
from rich.console import Console
|
|
11
|
+
|
|
12
|
+
app: Final = btask.newSubApp('加密')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@app.command()
|
|
16
|
+
@syncCall
|
|
17
|
+
async def encrypt_text():
|
|
18
|
+
'加密文本(使用剪贴板内容)'
|
|
19
|
+
content = pyperclip.paste()
|
|
20
|
+
assert content, '剪贴板内容不能为空'
|
|
21
|
+
bcolor.printGreen(content)
|
|
22
|
+
password = _genPassword()
|
|
23
|
+
result = bcrypto.encryptText(content, password).decode()
|
|
24
|
+
pyperclip.copy(result)
|
|
25
|
+
print('密文已复制到剪贴板')
|
|
26
|
+
bcolor.printYellow(result)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@app.command()
|
|
30
|
+
@syncCall
|
|
31
|
+
async def decrypt_text():
|
|
32
|
+
'解密文本(使用剪贴板内容)'
|
|
33
|
+
content = pyperclip.paste().strip()
|
|
34
|
+
bcolor.printYellow(content)
|
|
35
|
+
while True:
|
|
36
|
+
try:
|
|
37
|
+
password = getpass.getpass('输入密码:')
|
|
38
|
+
result = bcrypto.decryptText(content.encode(), password)
|
|
39
|
+
print('解密成功')
|
|
40
|
+
bcolor.printGreen(result)
|
|
41
|
+
return
|
|
42
|
+
except KeyboardInterrupt:
|
|
43
|
+
break
|
|
44
|
+
except BaseException:
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@app.command()
|
|
49
|
+
@syncCall
|
|
50
|
+
async def encrypt_json():
|
|
51
|
+
'生成JSON密文(使用剪贴板内容)'
|
|
52
|
+
content = pyperclip.paste()
|
|
53
|
+
try:
|
|
54
|
+
data = json.loads(content)
|
|
55
|
+
except:
|
|
56
|
+
return btask.abort('错误:剪贴板内容必须是JSON格式', content)
|
|
57
|
+
Console().print_json(data=data, indent=4, ensure_ascii=False, sort_keys=True)
|
|
58
|
+
password = _genPassword()
|
|
59
|
+
result = bcrypto.encryptJson(data, password).decode()
|
|
60
|
+
pyperclip.copy(result)
|
|
61
|
+
print('密文已复制到剪贴板')
|
|
62
|
+
bcolor.printYellow(result)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@app.command()
|
|
66
|
+
@syncCall
|
|
67
|
+
async def decrypt_json():
|
|
68
|
+
'还原JSON密文内容(使用剪贴板内容)'
|
|
69
|
+
content = pyperclip.paste().strip()
|
|
70
|
+
bcolor.printYellow(content)
|
|
71
|
+
while True:
|
|
72
|
+
try:
|
|
73
|
+
password = getpass.getpass('输入密码:')
|
|
74
|
+
data = bcrypto.decryptJson(content.encode(), password)
|
|
75
|
+
Console().print_json(data=data, indent=4, ensure_ascii=False, sort_keys=True)
|
|
76
|
+
return
|
|
77
|
+
except KeyboardInterrupt:
|
|
78
|
+
break
|
|
79
|
+
except BaseException:
|
|
80
|
+
pass
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@app.command()
|
|
84
|
+
@syncCall
|
|
85
|
+
async def encrypt_file(
|
|
86
|
+
file: Path = typer.Argument(..., help='指定需要加密的文件')
|
|
87
|
+
):
|
|
88
|
+
'加密文件(文件路径使用剪贴板内容)'
|
|
89
|
+
assert file.is_file(), '文件不存在'
|
|
90
|
+
password = _genPassword()
|
|
91
|
+
data = await bfile.readBytes(file)
|
|
92
|
+
result = bcrypto.encrypt(data, password)
|
|
93
|
+
await bfile.writeBytes(file, result)
|
|
94
|
+
bcolor.printYellow(result)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@app.command()
|
|
98
|
+
@syncCall
|
|
99
|
+
async def decrypt_file(
|
|
100
|
+
file: Path = typer.Argument(..., help='指定需要解密的文件')
|
|
101
|
+
):
|
|
102
|
+
'解密文件(文件路径使用剪贴板内容)'
|
|
103
|
+
assert file.is_file(), '文件不存在'
|
|
104
|
+
password = getpass.getpass('输入密码:')
|
|
105
|
+
data = await bfile.readBytes(file)
|
|
106
|
+
result = bcrypto.decrypt(data, password)
|
|
107
|
+
await bfile.writeBytes(file, result)
|
|
108
|
+
bcolor.printYellow(result)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _genPassword():
|
|
112
|
+
password = ''
|
|
113
|
+
while not password:
|
|
114
|
+
password = getpass.getpass('输入密码:')
|
|
115
|
+
while password != getpass.getpass('再次密码:'):
|
|
116
|
+
pass
|
|
117
|
+
return password
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bcmd
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.64
|
|
4
4
|
Summary: Commands for Beni
|
|
5
5
|
Author-email: Beni Mang <benimang@126.com>
|
|
6
6
|
Maintainer-email: Beni Mang <benimang@126.com>
|
|
7
7
|
Keywords: benimang,beni,bcmd
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
|
-
Requires-Dist: benimang ==0.5.
|
|
9
|
+
Requires-Dist: benimang ==0.5.16
|
|
10
10
|
Requires-Dist: pathspec
|
|
11
11
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
bcmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
bcmd/main.py,sha256=
|
|
2
|
+
bcmd/main.py,sha256=HfjQAidvC62HhmbjuR-NN3KM5pmqdTn1vaPwWsbp_ko,132
|
|
3
3
|
bcmd/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
bcmd/common/password.py,sha256=
|
|
5
|
-
bcmd/tasks/__init__.py,sha256=
|
|
4
|
+
bcmd/common/password.py,sha256=Wt1AK7PAZEsg7s6dU3zb-xAnNNGSaIyG1BmQNyHxKLY,1505
|
|
5
|
+
bcmd/tasks/__init__.py,sha256=GM2Qt251fgFSNxDPDq372RVbJgmmjL_3BX3HTqsR2WY,268
|
|
6
6
|
bcmd/tasks/bin.py,sha256=4O9Doak-ecOTGvyriZf6v31bhTI66s5IsIKV3wW_cu4,3082
|
|
7
|
+
bcmd/tasks/crypto.py,sha256=YMGh5E8-ki_z4j7EWc-c_XAE6pCRKPU6PiPF4149osw,3326
|
|
7
8
|
bcmd/tasks/download.py,sha256=jx3I4sNQiqKPuzqL2rwI8PK5-fXlzpChpeXrZ-MvEso,1052
|
|
8
9
|
bcmd/tasks/json.py,sha256=WWOyvcZPYaqQgp-Tkm-uIJschNMBKPKtZN3yXz_SC5s,635
|
|
9
10
|
bcmd/tasks/jwt.py,sha256=NhKbCO7DHS5pFeywyt8S-xaQgRgs5jCe8EN9OOhq4VA,2407
|
|
@@ -15,8 +16,8 @@ bcmd/tasks/task.py,sha256=7AelyK8mTVTfERaagkaUUggP8Md3XC9gurgoakMYf_I,4738
|
|
|
15
16
|
bcmd/tasks/temp.py,sha256=xLyYo2q6BX6OiaWG8NuyNmUCroVYrmtLzR2cZOUyFow,766
|
|
16
17
|
bcmd/tasks/time.py,sha256=nSIVYov2LsGdxsZAtC91UKXcUtVAqR9o-JmzeuevFhA,2586
|
|
17
18
|
bcmd/tasks/venv.py,sha256=aNVYAp0R52IdZ1tJi0fihjaZvy_3LH3L6pyQoS0qZqs,4127
|
|
18
|
-
bcmd-0.0.
|
|
19
|
-
bcmd-0.0.
|
|
20
|
-
bcmd-0.0.
|
|
21
|
-
bcmd-0.0.
|
|
22
|
-
bcmd-0.0.
|
|
19
|
+
bcmd-0.0.64.dist-info/METADATA,sha256=L6CVTGaKZ1Ry4lO1cLeRGJgx6XqXdXQgSBsGo8oyLjM,288
|
|
20
|
+
bcmd-0.0.64.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
21
|
+
bcmd-0.0.64.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
|
|
22
|
+
bcmd-0.0.64.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
|
|
23
|
+
bcmd-0.0.64.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|