我有一个数据帧,看起来像:
index name city
0 Yam Hadera
1 Meow Hadera
2 Don Hadera
3 Jazz Hadera
4 Bond Tel Aviv
5 James Tel Aviv
我希望Pandas随机选择值,使用city
列中出现的次数(有点使用:df.city.value_counts()
),因此我的魔术函数的结果,假设:
^{pr2}$
可能看起来像:
0 Yam Hadera
1 Meow Hadera
2 Bond Tel Aviv
谢谢!:)
Tags:
您的φ计算不正确。它必须是φ=(p-1)x(q-1),但它实际上是φ=(p-1)。你忘了把一个附加项乘以。换句话说:
参见维基百科关于RSA的文章
其他考虑:
未添加的(教科书)RSA不安全。您需要实现安全填充,例如OAEP
RSA本身只能加密数值小于模的内容。如果明文较大(不要忘记填充),则需要hybrid encryption
我觉得现在接受的答案有点误导,所以我想我会简单地编辑你的代码,加入@Artom B的评论。请将下面的代码与你的代码和@Krzysztof Cichoki发布的代码进行比较,看看你的错误在哪里。我还使用了
BigInteger.ONE
而不是new BigInteger("1")
,但这主要是一种表面上的改变以下是此程序一次运行的输出:
如果您仔细查看加密消息1801088541,您可能会推断出Artom在声明“未添加(教科书)RSA不安全”时提到的缺陷。您需要实现安全填充,例如OAEP。"
这对我来说是可行的,这是我写的非常旧的代码,但它是可行的,您需要实现pojo类,但这些类只包含数字,实现起来很简单。将每个步骤的结果与此进行比较,这将有助于调试代码
类密钥:
类素数:
相关问题 更多 >
编程相关推荐