import hashlib def encrypt(data): # 创建一个sha256的加密对象 encryptor = hashlib.sha256() # 将需要加密的数据传入加密对象 encryptor.update(data.encode('utf-8')) # 获取加密后的结果 encrypted_data = encryptor.hexdigest() # 返回加密后的结果 return encrypted_data # 在主程序中调用加密函数 data = 'Hello, World!' encrypted_data = encrypt(data) print(f'原始数据:{data}') print(f'加密后的数据:{encrypted_data}')Python中callfunction调用加密怎么实现
登录后复制