【发布时间】:2019-08-07 06:35:24
【问题描述】:
我正在尝试加密此数据集Wholesales customer,已删除前两列(通道和区域)。 加密脚本工作正常,因为我能够生成用于加密的公钥。但是,我认为问题在于嵌套的 for 循环行。任何帮助,将不胜感激。
from Paillier_CRT.gmpy2mod import *
import numpy as np
import pandas as pd
priv, pub = generate_keypair(128)
n = pub.n
print("The public key is:", n)
def to_encrypt(public, data_matrix):
data_encrypted = encrypt(public, data_matrix)
return data_encrypted
def load_data():
raw_data = pd.read_csv('wholesales1.csv')
dtset = raw_data.drop(['Channel'], axis=1)
new_dtset = dtset.drop(['Region'], axis=1)
converted_data = new_dtset.values
data_to_encrypt = []
for row in converted_data:
for elem in row:
data_to_encrypt = to_encrypt(pub, int(converted_data))
return data_to_encrypt
working_data = load_data()
print("The encrypted data is: ", working_data)
错误信息:
TypeError: only size-1 arrays can be converted to Python scalars
【问题讨论】:
标签: python arrays numpy scalar