algo_present/mem_present.py
2024-04-15 16:54:35 +08:00

24 lines
661 B
Python

import CoreAlgorithm as paillier
from memory_profiler import profile
# python -m memory_profiler mem_present.py
@profile
def main():
Public_Key, Private_Key = (
paillier.generate_paillier_keypair()
) # 随机生成1024长的公钥和私钥
x = 90000.23
y = 90
z = 0.5
x_encrypted = Public_Key.encrypt(x) # 加密后的x
y_encrypted = Public_Key.encrypt(y) # 加密后的y
z_encrypted = Public_Key.encrypt(z) # 加密后的z
t_encrypted = x_encrypted + y_encrypted * 0.5
print(f"x + y * 0.5的结果是:{Private_Key.decrypt(t_encrypted)}") # 打印出t
if __name__ == "__main__": # 主函数
main()