freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

rsa加密算法設(shè)計(編輯修改稿)

2025-07-26 18:26 本頁面
 

【文章內(nèi)容簡介】 ult)。 SetZero(temp)。 memset(flag,0,400)。 //將flag數(shù)組清零 i=399。 IntCpy(buf,B)。 //將B拷貝到buf中 while(IntCmp(buf,ZEROVALUE)==1) //如果buf內(nèi)容為0 { SetMode(buf,TWOVALUE,temp,result)。 //將buf進(jìn)行大數(shù)的模2運算,商在result中,余數(shù)temp flag[i]=temp[DATALENGTH1]。 IntCpy(buf,result)。 //對商繼續(xù)進(jìn)行模2運算 i。 } flag[i]=1。 //設(shè)置一個標(biāo)志位,表明二進(jìn)制數(shù)的開始}/*功能:該函數(shù)用來進(jìn)行模冪算法,A為底數(shù),模為c,二進(jìn)制的指數(shù)B存放在數(shù)組flag中入口參數(shù):底數(shù)A,模C,結(jié)果D,二進(jìn)制質(zhì)數(shù)flag[400]返回值:A^B=1(mod C),返回1;A^B=p1(mod C),返回2;否則返回0*/int CRsaA::PowerMode(byteint A,byteint C,byteint D,signed char flag[400]){ byteint buf。 byteint result。 byteint temp,P。 register i。 SetZero(D)。 SetZero(buf)。 SetZero(result)。 SetZero(temp)。 SetZero(P)。 //將D清零 IntCpy(temp,A)。 /將A的值拷貝到temp中if(flag[399]==1) //最低位為1,拷貝本身,flag[i]只有1或者0兩種情況 IntCpy(result,A)。 else //最低位為0,則冪為1 IntCpy(result,ONEVALUE)。 i=398。 while(flag[i]!=1) //判斷是否已經(jīng)到達(dá)指數(shù)盡頭 { Multiply(temp,temp,buf)。 //temp*tempbuf SetMode(buf,C,temp,P)。 //buf%c余數(shù)temp,商pif(flag[i]!=0) //如果該位不是0則將其和前一步低一位的結(jié)果進(jìn)行乘法運算{ //否則,將其作為該位的模,在高一位的運算中,只要進(jìn)行一次Multiply(temp,result,buf)。 //平方運算,就可以得到高一位的模 SetMode(buf,C,result,P)。 } i。 } //result中存放的是最終結(jié)果 IntCpy(buf,C)。 IntCpy(D,result)。 Substract(buf,ONEVALUE,temp)。 if(IntCmp(result,ONEVALUE)==0) return 1。 if(IntCmp(result,temp)==0) return 0。}/*功能:產(chǎn)生一個質(zhì)數(shù)入口參數(shù):大數(shù)Prm返回值:產(chǎn)生成功,返回0*/int CRsaA::Prime(byteint Prm){ int i,k,ok。 signed char flag[400]。 byteint A,B,D,buf1,buf2。 SetZero(A)。 SetZero(B)。 SetZero(D)。 SetZero(buf1)。 SetZero(buf2)。 while(1) //一直循環(huán)直到找到一個素數(shù)為止 { int pass=0。 srand( (unsigned)time( NULL ) )。 //初始化srand IntRandom(B,MLENGTH)。 IntCpy(Prm,B)。 //將B拷貝到prm中 C=N result primeSubstract(B,ONEVALUE,buf1)。 //將BONEVALUE的結(jié)果放到buf1中SetMode(buf1,TWOVALUE,buf2,B)。 //B=(B1)/2的商,buf2=(B1)/2的余數(shù) TransBi(B,flag)。 //將B轉(zhuǎn)換為二進(jìn)制大數(shù) ok=1。 for(i=0。iTESTNUM。i++) {LoadInt(A,Model[i])。 //將數(shù)組Model中的第i+1個數(shù)讀取到A中 k=PowerMode(A,Prm,D,flag)。 //(A^flag) mod Prm k if(k!=1 amp。amp。 k!=2) //不符合判定規(guī)則 { ok=0。 break。 } if(k==1) //判定條件1,G=A^(n1)/2=1 { } if(k==2) //判定條件2,G=A^(n1)/2=p1 { } } if (ok)//if(ok amp。amp。 pass_2) { return 0。}//for循環(huán)用來檢測IntRandom(B,MLENGTH)產(chǎn)生的數(shù)B是否是一個素數(shù) }}/*功能:計算公鑰PK入口參數(shù):$(r)的值在Rvalue中,私鑰SK,公鑰PK返回值:成功找到,返回1*/int CRsaA::ComputingPK(byteint Rvalue,byteint SK,byteint PK){ register i。 byteint PA,PB,PC,buf1,temp,buf2。 SetZero(PK)。 SetZero(PA)。 SetZero(PB)。 SetZero(PC)。 SetZero(buf1)。 //清零初始化 SetZero(temp)。 SetZero(buf2)。 while(1) { IntRandom(SK,SKLENGTH)。 IntCpy(PB,SK)。 IntCpy(PA,Rvalue)。 while(1) { SetMode(PA,PB,PC,PK)。 //PA=PB*PK+PC i=IntCmp(PC,ONEVALUE)。 if(i==0) //PC=1, i=0 break。 //滿足條件,是互質(zhì)的 i=IntCmp(PC,ZEROVALUE)。 if(i==0) { i=1。 //PC=0,i=1 break。 //不滿足互質(zhì)條件,跳出循環(huán),從新生成一個隨機數(shù) } IntCpy(PA,PB)。 //按照歐幾里的定理繼續(xù)判斷 IntCpy(PB,PC)。 } if(i==0) //滿足,跳出查找循環(huán) break。 } IntCpy(temp,ONEVALUE)。 IntCpy(PA,Rvalue)。 IntCpy(PB,SK)。 while(1) { Multiply(PA,temp,buf1)。 //buf1=PA*temp Plus(buf1,ONEVALUE,buf2)。//buf2=(PA*temp)+1 SetMode(buf2,PB,buf1,PK)。//buf2=((PA*temp)+1)%PB if(IntCmp(buf1,ZEROVALUE)==0) break。 Plus(temp,ONEVALUE,buf1)。 IntCpy(temp,buf1)。 } return 1。 //SK and PK found}/*
點擊復(fù)制文檔內(nèi)容
語文相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1