
Lv.1
专业Python程序员,木马病毒撰写者,专注于实体机开发
签名:$
在 一种奇怪的加密法(母亲节娱乐篇) 中回复
import os
import time
#主函数
def main():
getInput()
#输入参数
def getInput():
#获取操作的参数
while(True):
oper = input("请输入操作(e:加密 d:解密):")
if(oper=="e" or oper=="d"):
break
else:
print("输入有误,请重新输入!")
#获取文件密码
while(True):
password= input("请输入密码:")
if(len(password)==0):
print("密码不能为空!")
else:
break
#获取操作的文件路径
while(True):
path=input(r"请输入文件路径:")
try:
f_read = open(path,"rb")
except:
print("文件没有找到,请检查路径是否存在!")
else:
break
#进行加密或解密操作
if(oper=="e"):
encrypt(path,password)
elif(oper=="d"):
decrypt(path, password)
#加密
def encrypt(path,password):
#写个算法获取这些信息也没什么难度
fileFullName = path.split(os.path.sep) #os.path.sep为操作系统的文件分隔符
fileName = fileFullName[len(fileFullName)-1].split(".")[0]
fileSuffix = fileFullName[len(fileFullName)-1].split(".")[1]
# print("文件全名称:",fileFullName[len(fileFullName)-1])
# print("文件名称:",fileName)
# print("文件后缀:",fileSuffix)
fileParent = path[0:len(path)-len(fileFullName[len(fileFullName)-1])]
newFileName="加密_"+fileFullName[len(fileFullName)-1]
newFilePath=fileParent+newFileName
# print("文件父路径:",fileParent)
# print("新的文件名称:",newFileName)
# print("新的文件全路径:", newFilePath)
f_read = open(path,"rb")
f_write = open(newFilePath,"wb")
count=0 #当前密码加密索引
#我们采用异或循环加密
for now in f_read:
for nowByte in now:
newByte=nowByte^ord(password[count%len(password)])
count+=1
f_write.write(bytes([newByte]))
f_read.close()
f_write.close()
print("文件加密完毕")
time.sleep(3)
#解密(因为采取的异或解密,所以其实和加密算法一样)
def decrypt(path, password):
#写个算法获取这些信息也没什么难度
fileFullName = path.split(os.path.sep) # os.path.sep为操作系统的文件分隔符
fileName = fileFullName[len(fileFullName) - 1].split(".")[0]
fileSuffix = fileFullName[len(fileFullName) - 1].split(".")[1]
# print("文件全名称:", fileFullName[len(fileFullName)-1])
# print("文件名称:", fileName)
# print("文件后缀:", fileSuffix)
fileParent = path[0:len(path) - len(fileFullName[len(fileFullName)-1])]
newFileName = "解密_" + fileFullName[len(fileFullName) - 1]
newFilePath = fileParent + newFileName
# print("文件父路径:", fileParent)
# print("新的文件名称:", newFileName)
# print("新的文件全路径:", newFilePath)
f_read = open(path, "rb")
f_write = open(newFilePath, "wb")
count = 0 # 当前密码加密索引
# 采用异或循环加密
for now in f_read:
for nowByte in now:
newByte = nowByte ^ ord(password[count % len(password)])
count += 1
f_write.write(bytes([newByte]))
f_read.close()
f_write.close()
print("文件解密完毕")
time.sleep(3)
main()
2022-05-08T20:05:47 点赞:0
在 有哪位Python大师跟我合作,神回复 中回复
如果是小白,建议用IDLE,pycharm,sublime Text3,如果是大项目,建议用sublime text3
2022-05-14T15:02:02 点赞:0
在 C++如何做简单游戏(大佬勿入) 中回复
还有一点,C语言的窗口大小有限,搞不好会超出窗口范围,以及有时候会卡住(电脑性能不好说),可以尝试用绘制图形的方法改进一下
2022-05-14T15:36:16 点赞:0
在 dll注入和后台获取用户输入(在用户不知道的情况下) 中回复
由于键盘顺序号编码的问题,用户输入的“1”会被转译成“Q”因为“Q”和“1”的顺序号是一样的,所有数字键都有这个问题,目前作者正在解决,会在评论区公布源码。
2022-08-11T10:27:39 点赞:0
在 【Python作品分享】Ursina-3D游戏1 中回复
给个建议,我一般写游戏是像:
class ClassName(Entity):
def __init__(self,position):
super().__init__(
parent=xxx,
model="xxx",
texture=xxx,
color=xxx,
position=xxx,
origin_y=xxx
)
这样来定义实体的,建议这样写代码,更好理解。
2022-08-25T19:31:40 点赞:0
在 【python】3D迷宫代码 中回复
在开头加一下这段代码就行:
FB =b'图片字节'
bytes(FB) #防止格式不对
with open("cms.png","wb") as f:
f.write(FB)
f.close()2022-09-17T13:10:37 点赞:0