我们提供消息推送系统招投标所需全套资料,包括消息推送系统介绍PPT、消息推送系统产品解决方案、
消息推送系统产品技术参数,以及对应的标书参考文件,详请联系客服。
def encrypt_data(data, key):
from Crypto.Cipher import AES
cipher = AES.new(key, AES.MODE_EAX)
nonce = cipher.nonce
ciphertext, tag = cipher.encrypt_and_digest(data.encode())
return nonce, ciphertext, tag
key = b'your_secret_key_'
data = "PatientID: 12345"
nonce, ciphertext, tag = encrypt_data(data, key)
print("Encrypted Data:", ciphertext)
]]>
class User:
def __init__(self, username, role):
self.username = username
self.role = role
class AccessControl:
def __init__(self):
self.users = {}
def add_user(self, user):
self.users[user.username] = user
def check_access(self, username, permission):
if username in self.users:
user = self.users[username]
if user.role == 'admin':
return True
elif user.role == 'doctor' and permission == 'view_patient_data':
return True
else:
return False
return False
# Example usage
access_control = AccessControl()

access_control.add_user(User('alice', 'admin'))
access_control.add_user(User('bob', 'doctor'))
print(access_control.check_access('alice', 'view_patient_data')) # 输出: True
print(access_control.check_access('bob', 'view_patient_data')) # 输出: True

print(access_control.check_access('bob', 'edit_patient_data')) # 输出: False
]]>