📄 ts.cpp
字号:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <iostream.h>
#include "Bignum.cpp"
CBigNum GenerateBigRandomNumber(unsigned short nBytes)
{
CBigNum Result=0U; // 初始化大数
int i;
clock_t ctStart;
unsigned long ctr=0;
// 设置时间间隔
clock_t ctInterval = CLOCKS_PER_SEC / 50 + 1;
for (i=0; i<nBytes*2; i++)
{
ctStart = clock();
// 等到大于时间间隔再开始
while (clock() - ctStart < ctInterval)
ctr++;
ctr = (ctr % 33) & 0xF;
Result <<= 4U; // 大数左移4位
Result |= ctr; // 做或运算
}
putchar('\n');
return Result; // 返回大数
}
void main()
{
//long int h;
int nBytes=64;
//int start=clock(); //开始计时
// 生成随机大数
CBigNum x,e,n,t,c;
x=GenerateBigRandomNumber( nBytes);
e=GenerateBigRandomNumber( nBytes);
n=GenerateBigRandomNumber( nBytes);
c=x.PowMod(e,n);
//作x的e次方mod n的运算
/* int end=clock(); //计时结束
int time;
cout<<"x="<<x<<'\n'<<'\n';
cout<<"e="<<e<<'\n'<<'\n';
cout<<"n="<<n<<'\n'<<'\n';
time=end-start;
printf("The time of this operation is:%d",time);*/
printf("\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -