bcmd 0.0.63__tar.gz → 0.0.64__tar.gz
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-0.0.63 → bcmd-0.0.64}/PKG-INFO +2 -2
- bcmd-0.0.64/bcmd/common/password.py +34 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/main.py +1 -1
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/__init__.py +1 -0
- bcmd-0.0.64/bcmd/tasks/crypto.py +117 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd.egg-info/PKG-INFO +2 -2
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd.egg-info/SOURCES.txt +1 -0
- bcmd-0.0.64/bcmd.egg-info/requires.txt +2 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/pyproject.toml +2 -2
- bcmd-0.0.63/bcmd/common/password.py +0 -34
- bcmd-0.0.63/bcmd.egg-info/requires.txt +0 -2
- {bcmd-0.0.63 → bcmd-0.0.64}/MANIFEST.in +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/README.md +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/__init__.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/common/__init__.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/bin.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/download.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/json.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/jwt.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/lib.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/math.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/mirror.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/proxy.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/task.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/temp.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/time.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd/tasks/venv.py +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd.egg-info/dependency_links.txt +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd.egg-info/entry_points.txt +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/bcmd.egg-info/top_level.txt +0 -0
- {bcmd-0.0.63 → bcmd-0.0.64}/setup.cfg +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import getpass
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from beni import bcache, bcrypto
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@bcache.cache
|
|
8
|
+
async def getPypi() -> tuple[str, str]:
|
|
9
|
+
content = 'pypi.org gAABl0ruN3xd3bOT6kGy-Zpb8liT7Qzan7jC3c9nR7mvmoaC3QVJuWl11-9vArCK8AQq_ML5_ghAnW7i2tSQ00W2DITy_eYzwaKLPHz42KSLp5vPkOOmAIWDSBIzVYizDgE1wkDL8TxAGjRvS4nWD1LVAgEC5PSrck4uLw5dDrfa-z_C0WZYaHLMLdmDQ0d060ac7bb8fc523AAAvPXGB2B8ZMT6qnk08ExNYHuYDwCxixIv1FEBRPEEV7q_cCZpYvplscWh1oUKDDFy1gqH0jjvFn7-Fai2y4MGO9Wz081CglHkT66H8MdHa027rc-vdvS-Guk2pIXgExlwtiAFHjQVJLler5pbOk-obuLRIxNqs5ibRuaymMQ4NLZI8G6mH5-NB3M=4058304a696d7f92c'
|
|
10
|
+
data = _getData(content)
|
|
11
|
+
return data['username'], data['password']
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@bcache.cache
|
|
15
|
+
async def getQiniu() -> tuple[str, str]:
|
|
16
|
+
content = '七牛云 gAABl0RjrmaAQv8ByatIWP0du5igDBP_28GffENjKvw9KQI1lGGeweOO_T01OL-LBUPlJ8SXIOPIv1obubke8Zv_JzyLpBkpVhpJLusDxbcLSUjjT0ce3f1b4f89fd698A3AAvQBXU8UuPUw2FrBKx2EVVhtWim2Oj_pI_B4QD6K-IP9_kHWixTenckI_Lcnw4KPSJIDRmCmtSb4RS45cVLlc4Umd4UT4smTYYlH34BA2RSEbQ==63b3af29f373954f0'
|
|
17
|
+
data = _getData(content)
|
|
18
|
+
return data['ak'], data['sk']
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _getData(content: str) -> dict[str, Any]:
|
|
22
|
+
index = content.find(' ')
|
|
23
|
+
if index > -1:
|
|
24
|
+
tips = f'请输入密码({content[:index]}):'
|
|
25
|
+
else:
|
|
26
|
+
tips = '请输入密码:'
|
|
27
|
+
while True:
|
|
28
|
+
try:
|
|
29
|
+
pwd = getpass.getpass(tips)
|
|
30
|
+
return bcrypto.decryptJson(content.encode(), pwd)
|
|
31
|
+
except KeyboardInterrupt:
|
|
32
|
+
raise Exception('操作取消')
|
|
33
|
+
except BaseException:
|
|
34
|
+
pass
|
|
@@ -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,10 +1,10 @@
|
|
|
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
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = 'bcmd'
|
|
6
|
-
version = '0.0.
|
|
6
|
+
version = '0.0.64'
|
|
7
7
|
description = 'Commands for Beni'
|
|
8
8
|
requires-python = '>=3.10'
|
|
9
9
|
keywords = ['benimang', 'beni', 'bcmd']
|
|
@@ -12,7 +12,7 @@ maintainers = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
dependencies = [
|
|
15
|
-
'benimang==0.5.
|
|
15
|
+
'benimang==0.5.16',
|
|
16
16
|
'pathspec',
|
|
17
17
|
]
|
|
18
18
|
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import getpass
|
|
2
|
-
from typing import Any
|
|
3
|
-
|
|
4
|
-
from beni import bcache, bjwt
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@bcache.cache
|
|
8
|
-
async def getPypi() -> tuple[str, str]:
|
|
9
|
-
content = 'pypi.org eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Il9fdG9rZW5fXyIsInBhc3N3b3JkIjoicHlwaS1BZ0VJY0hsd2FTNXZjbWNDSkRrM05qWTFOMk5tTFRsaU9URXROR0ZsT1MwNVlUQTBMVFE0WVQ2NlTzlIbkx4RG9Ca3ciLCIzMGE0YTM1Ni0zNmYwLTQ4NTktODk3Zi0xZDFmZDRkMmVhMWQiOjE3MDA4NDU1ODQuNDg5MTY2fQ.YjsYWtUxfsDbHJRQiFSzfuNKDnccC3gxGbAk_bW-LBARCak5EUmlOR1ppWVFBQ0tsc3pMQ0ppT0RBMU16QmhaUzFrTURZekxUUTBZbVF0T0dJMU1pMHdNMlZqWVRSaFlUYzJZV1lpWFFBQUJpQWNvaWxLNlA2TVNZSklETnlvXzcwTXkybzVPWWR3'
|
|
10
|
-
data = _getData(content)
|
|
11
|
-
return data['username'], data['password']
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@bcache.cache
|
|
15
|
-
async def getQiniu() -> tuple[str, str]:
|
|
16
|
-
content = '七牛云 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhayI6Ik8td1lkdzA1Q05fLThoLUFKYmZDWTRqN2VoRkJTcEdiQTlyNlhOUk4iLCJzayI6InQxZWI5ZDI4YzNhZWMiOjE2OTY5MjI0MjAuNTgzMzkzNn0.4pn5edULuUmgo_pTpcoPE1Cxwxq5W81CjSeTCmnaEyEyNjAtck5ZUlJNZ29tSUcwZ0Rtakp2T2o1VmNjdTFWMzJHZHFFY2UiLCIyMzE4NmNlMy01MTI0LTRjMWItYjIzZC0'
|
|
17
|
-
data = _getData(content)
|
|
18
|
-
return data['ak'], data['sk']
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def _getData(content: str) -> dict[str, Any]:
|
|
22
|
-
index = content.find(' ')
|
|
23
|
-
if index > -1:
|
|
24
|
-
tips = f'请输入密码({content[:index]}):'
|
|
25
|
-
else:
|
|
26
|
-
tips = '请输入密码:'
|
|
27
|
-
while True:
|
|
28
|
-
try:
|
|
29
|
-
pwd = getpass.getpass(tips)
|
|
30
|
-
return bjwt.decodeJson(content, pwd)
|
|
31
|
-
except KeyboardInterrupt:
|
|
32
|
-
raise Exception('操作取消')
|
|
33
|
-
except BaseException:
|
|
34
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|