我有一个游戏(石头、布、剪刀)。 如何使用HMAC(SHA-2或SHA-3)加密计算机的答案,并在游戏结束时与用户的答案进行比较?你知道吗
import random
import hmac
import hashlib
import base64
options = {"r": "rock", "p": "paper", "s": "scissors"}
while True:
user = input('Choose r for rock, p for paper, s for scissors or q to quit: ')
user = user.lower()
if user == 'q':
break
if user not in options.keys():
continue
choice = random.choice(list(options.keys()))
print('Computer picked:', options[choice])
if choice == user:
print('You tie against the computer\n')
elif (user, choice) in (("r", "s"), ("p", "r"), ("s", "p")):
print('You win against the computer\n')
else:
print('You lose against the computer\n')
目前没有回答
相关问题 更多 >
编程相关推荐