当前位置:网站首页>[密码学实验] 0x00 安装NTL库
[密码学实验] 0x00 安装NTL库
2022-07-29 07:53:00 【吉计小菜鸡】
这里用的是vs2022
编译NTL库
1.先创建静态库项目
2.将NTL包下src下所有文件添加到项目中工程右键->添加->现有项选择所有文件
3.项目右击,属性C/C++->常规源码包中include文件目录加到附加包含目录;将SDL检查设置为否C/C++->预编译头 不使用预编译头
(点击属性名称就可以改预设属性)
4.编译
VS顶部菜单栏生成->生成解决方案
编译完成后会生成lib文件
在项目目录下(这里我的项目名称是NTL_CPP)
复制下来这个路径,本次是E:\projects\test-project\NTL_CPP\x64\Debug
使用NTL库
现在创建一个要使用NTL库的项目
在要使用的项目右击选择属性
将源码包的Include文件夹路径添加到外部包含目录中,同时将SDL检查设置为否

链接器->常规->附加库目录添加.lib文件的路径


再把.lib文件名加到附加依赖项中

测试NTL库是否可使用
用一段RSA代码(来源是这位大佬的文章)测试,出现了error
#include<iostream>
#include<NTL/ZZ.h>
using namespace NTL;
int main(){
ZZ p, q, n, phi_of_n, public_key, private_key, message;
int no_of_bits;
std::cout<<"Enter no of bits : ";
std::cin>>no_of_bits;
// generating p and q prime numbers
p = GenPrime_ZZ(no_of_bits, 80);
q = GenPrime_ZZ(no_of_bits, 80);
n = p * q;
phi_of_n = (p-1)*(q-1);
ZZ i = (ZZ)1;
long bits_of_n = 0;
for( ; i <= n; i *= 10) {
bits_of_n++;
}
public_key = GenPrime_ZZ(bits_of_n/2, 80);
private_key = InvMod(public_key, phi_of_n);
std::cout<<"\nEnter Message to decrypt : ";
std::cin>>message;
// Encryption of message using public key
ZZ encrypted_message = PowerMod(message, public_key, n);
ZZ decrypted_message = PowerMod(encrypted_message, private_key, n);
std::cout<<"\np = "<<p<<"\n";
std::cout<<"\nq = "<<q<<"\n";
std::cout<<"\nn = "<<n<<"\n";
std::cout<<"\nphi of n = "<<phi_of_n<<"\n";
std::cout<<"\npublic key = "<<public_key<<"\n";
std::cout<<"\nprivate key = "<<private_key<<"\n";
std::cout<<"\nprivate key * public key (mod phi_of_n)= "<<MulMod(public_key, private_key, phi_of_n)<<"\n";
std::cout<<"\nEncrypted Message = "<<encrypted_message<<"\n";
std::cout<<"\nDecrypted Message = "<<decrypted_message<<"\n";
return 0;
}

4146,一波询问S同学发现是cpp文件里的SDL检查
改完后再运行一下,变成了warning,可以跑了


运行成功
边栏推荐
- Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
- Data warehouse modeling, what is wide table? How to design? Advantages and disadvantages
- Cs61abc sharing session (VI) detailed explanation of program input and output - standard input and output, file, device, EOF, command line parameters
- 输出1234无重复的三位数
- @JsonSerialize注解的使用
- [summer daily question] Luogu p4414 [coci2006-2007 2] ABC
- Data unit: bit, byte, word, word length
- Pat class a 1146 topology sequence
- Matlab simulation of LDPC minimum sum decoding based on high-order six ring free
- IonIcons图标大全
猜你喜欢

207.课程表

Use custom annotations to verify the size of the list

Jianmu continuous integration platform v2.5.2 release

Keyboard processing in jetpack compose
![[cryoelectron microscope] relation4.0 - subtomogram tutorial](/img/5b/5364fbe68c495b67d9db5ed9bec2ac.png)
[cryoelectron microscope] relation4.0 - subtomogram tutorial

2022 Shenzhen Cup Title A: get rid of "scream effect" and "echo room effect" and get out of the "information cocoon room"

@JsonSerialize注解的使用

10 practical uses of NFT

Solve the problem that CSDN cannot publish blog due to unknown copyright

Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
随机推荐
佳木斯市场监管局开展防疫防虫害专题食品安全网络培训
C language data type
Jump from mapper interface to mapping file XML in idea
Matlab simulation of LDPC minimum sum decoding based on high-order six ring free
[dry goods memo] 50 kinds of Matplotlib scientific research paper drawing collection, including code implementation
Volatile keyword parsing of C #
[lecture notes] how to do in-depth learning in poor data?
基于高阶无六环的LDPC最小和译码matlab仿真
[introduction to cryoelectron microscopy] Caltech open class course notes part 3:image formation
在一个sql文件中,上面定义一个测试表及数据,下面可以select* from 测试表
NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression
[summer daily question] Luogu p4413 [coci2006-2007 2] R2
[freeze electron microscope] analysis of the source code of the subtomogram alignment function of relion4.0 (for self use)
Technology sharing | quick intercom integrated dispatching system
What is the use of chat robots? What type? After reading these, you will understand!
[cryoelectron microscope | paper reading] a feature guided, focused 3D signal permutation method for subtogram averaging
2022 Shenzhen Cup Title A: get rid of "scream effect" and "echo room effect" and get out of the "information cocoon room"
Dilworth 定理
JVM garbage collection mechanism (GC)
Do you want to meet all the needs of customers