?? ts.cpp
字號(hào):
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <iostream.h>
#include "Bignum.cpp"
CBigNum GenerateBigRandomNumber(unsigned short nBytes)
{
CBigNum Result=0U; // 初始化大數(shù)
int i;
clock_t ctStart;
unsigned long ctr=0;
// 設(shè)置時(shí)間間隔
clock_t ctInterval = CLOCKS_PER_SEC / 50 + 1;
for (i=0; i<nBytes*2; i++)
{
ctStart = clock();
// 等到大于時(shí)間間隔再開(kāi)始
while (clock() - ctStart < ctInterval)
ctr++;
ctr = (ctr % 33) & 0xF;
Result <<= 4U; // 大數(shù)左移4位
Result |= ctr; // 做或運(yùn)算
}
putchar('\n');
return Result; // 返回大數(shù)
}
void main()
{
//long int h;
int nBytes=64;
//int start=clock(); //開(kāi)始計(jì)時(shí)
// 生成隨機(jī)大數(shù)
CBigNum x,e,n,t,c;
x=GenerateBigRandomNumber( nBytes);
e=GenerateBigRandomNumber( nBytes);
n=GenerateBigRandomNumber( nBytes);
c=x.PowMod(e,n);
//作x的e次方mod n的運(yùn)算
/* int end=clock(); //計(jì)時(shí)結(jié)束
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");
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -