- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 NTL library实现 ElGamal 加密/解密算法。我已经知道它可以正常工作了,但是算法希望将消息转换为整数,以便对其进行加密。
因此,如果我输入像 1234 这样的数字,一切正常,但我如何才能将 C++ 字符串 (std::string) 转换为 ZZ 数字,然后从该 ZZ 数字返回到字符串?
LE:
ZZ是代表大数的类。
例如:18287348238476283658234881728316274273671623781254124517353
所以基本上我想以“Hello World”为例,逐个字符地运行它并获取字符的 ascii 代码,这样我就会得到一个数字:“72 101 108 108 111 32 87 111 114 108 100"
然后我需要将这个数字转换回字符串“Hello World”
或者也许有更好的方法。
最佳答案
这是来自 NTL 作者网站的答案:
In addition to the conversions listed, there is a generic conversion from a C-strings (i.e., const char *) to any type T, which is implemented using templates using the input operator >> for type T. So, for example, you can write
ZZ x = conv<ZZ>("99999999999999999999999");
来源:http://www.shoup.net/ntl/doc/conversions.txt
我试过了,效果很好。
关于c++ - 如何将字符串转换为 ZZ 数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2117312/
我是一名优秀的程序员,十分优秀!