import hmac
def zhuCe():
salt = "@#$jskd"
n = input("请输入账户")
f = open("password1.txt", mode="a")
f.write(n+"n")
f.close()
m = input("请输入密码")
md5 = hmac.new(m.encode("utf-8"), salt.encode("utf-8"), "md5")
y = md5.hexdigest()
f = open("password1.txt", mode="a")
f.write(y+"n")
f.close()
print("账户创建完毕请登录")
dengLu()
def dengLu():
salt = "@#$jskd"
n = str(input("请输入您的账户"))
m = str(input("请输入您的密码"))
md5 = hmac.new(m.encode("utf-8"), salt.encode("utf-8"), "md5")
m2 = md5.hexdigest()
f = open("password1.txt", mode="rt")
l = f.readline().replace("\n","")
while True:
if l == n:
f = open("password1.txt", mode="rt")
l = f.readline().replace("\n","")
while True:
if l == m2:
print("登录成功")
break
else:
l=f.readline().replace("\n","")
break
f.close()
else:
l=f.readline().replace("\n","")
if not l:
print("账户或密码错误错误")
break
f.close()
#
#
i = int(input("如果您想登录请按1,如果注册请按2"))
if i == 1:
dengLu()
elif i == 2:
zhuCe()
class Shcpe():
def __init__(self,center_x,center_y):
self.center_x=center_x
self.center_y=center_y
class Rectangle(Shcpe):
def __init__(self,center_x,center_y,center_h,center_w):
super().__init__(center_x, center_y)
self.center_h=center_h
self.center_w=center_w
def is_in(self, x, y):
if (x >= self.center_x - self.width / 2 and x <= self.center_x + self.width / 2) and (
y >= self.center_y - self.height / 2 and y <= self.center_y + self.height / 2):
return True
else:
return False
class circle(Shcpe):
def __init__(self,center_x,center_y,radius):
super().__init__(center_x, center_y)
self.radius=radius
def is_in(self, x, y):
if (x - self.center_x) ** 2 + (y - self.center_y) ** 2 <= self.radius ** 2:
return True
else:
return False
用python实现一个登录程序
于 2023-12-14 13:43:32 首次发布