团队作业(五):项目冲刺3
各个成员今日完成的任务
范超明:继续完善前端代码
周意凯:继续加密解密代码修改
黄琪凯:继续完善后端代码
尤其羽:继续完善后端代码
杨语桐:代码测试
代码完成情况
前端新增部分代码
`def read_user_info(sm4_key):
directory = "user"
for user in os.listdir(directory):
decrypt_one_file(user, directory, sm4_key)
user = user[:-len(".encrypted")]
with open(os.path.join(directory, user), 'r') as user_info:
users[user] = user_info.read().strip()
encrypt_one_file(user, directory, sm4_key)
def write_user_info(sm4_key):
directory = "user"
for user, password in users.items():
if user + ".encrypted" in os.listdir(directory):
continue
else:
with open(os.path.join(directory, user), 'w') as user_info:
user_info.write(password)
encrypt_one_file(user, directory, sm4_key)`
后端新增部分代码
def add_user():
user = input("input the username: ")
if user in users:
print("error, the user exists")
return
password = input("input the password: ")
try:
users[user] = password
except:
print("error when adding user, exit")
return
print("add the user: %s successfully" % user)
加密解密部分新增代码
`def decrypt_file(file_path, sm4_key):
# 执行解密操作
crypt_sm4 = sm4.CryptSM4()
crypt_sm4.set_key(sm4_key, sm4.SM4_DECRYPT)
try :
# print(file_path)
with open(file_path, 'rb') as encrypted_file:
encrypted_data = encrypted_file.read()
except:
print("an error occurred while opening the data, exit ")
return
decrypted_data = crypt_sm4.crypt_ecb(encrypted_data)
# 保存解密后的文件(去除 .encrypted 后缀)
original_file_path = file_path.rsplit('.encrypted', 1)[0]
with open(original_file_path, 'wb') as file:
file.write(decrypted_data)
# 删除加密文件(可选)
os.remove(file_path)
# print("decrypt the file successfully")`
提交到gitee
明日各个成员的任务安排
范超明:继续完善前端代码
周意凯:继续加密解密代码修改
黄琪凯:继续完善后端代码
尤其羽:继续完善后端代码
杨语桐:代码测试
各个成员今日对项目的贡献量
姓 名 | 贡献量 |
---|---|
范超明 | 2 |
周意凯 | 2 |
黄琪凯 | 2 |
尤其羽 | 2 |
杨语桐 | 2 |