91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 17.88MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2024-01-30
  • 語言: Java
  • 標簽: 密碼學(xué)??Java??

資源簡介

本代碼主要用于實現(xiàn)RSA數(shù)字簽名算法,用java進行編程,能夠完整的在eclipse上運行,具體可用于密碼學(xué)的課程設(shè)計等。

資源截圖

代碼片段和文件信息

package?aaa;

import?java.io.*;
import?java.math.BigInteger;
import?java.util.ArrayList;




public?class?EnAndDe?{
private?long?p?=?0;
private?long?q?=?0;
private?long?n?=?0;
private?long?t?=?0;?//?歐拉函數(shù)

private?long?e?=?0;?//?公匙
private?long?d?=?0;?//?密匙

private?String?mc;?//?明文
private?long?c?=?0;?//?密文
private?long?word?=?0;?//?解密后明文

//?判斷是一個數(shù)?x?否為素數(shù)素數(shù)就是判斷在?(2√x)范圍內(nèi)有沒有除1外的因數(shù)如果沒有則x數(shù)素數(shù)
public?boolean?isPrime(long?t)?{
long?k?=?0;
k?=?(long)?Math.sqrt((double)?t);
for?(int?i?=?2;?i?<=?k;?i++)?{
if?((t?%?i)?==?0)?{
return?false;
}
}
return?true;
}

//?隨機產(chǎn)生大素數(shù)(1e6數(shù)量級,注意,太大了要超出范圍)
public?void?bigprimeRandom()?{
do?{
p?=?(long)?(Math.random()?*?1000);
}?while?(!this.isPrime(p));
do?{
q?=?(long)?(Math.random()?*?100000);
}?while?(p?==?q?||?!this.isPrime(q));
}

//?輸入PQ
public?void?inputPQ()?throws?Exception?{

this.bigprimeRandom();
System.out.println(“自動生成兩個大素數(shù)pq分別為:“?+?this.p?+?“?“?+?this.q);

this.n?=?(long)?p?*?q;
this.t?=?(long)?(p?-?1)?*?(q?-?1);

System.out.println(“這兩個素數(shù)的乘積為p*q:“?+?this.n);
System.out.println(“所得的t=(p-1)(q-1):“?+?this.t);
}

//?求最大公約數(shù)
public?long?gcd(long?a?long?b)?{
long?gcd;
if?(b?==?0)
gcd?=?a;
else
gcd?=?gcd(b?a?%?b);
return?gcd;

}

//?生成公匙
public?void?getPublic_key()?throws?Exception?{
do?{

this.e?=?17;
//?e滿足?e∈(1?ψ(n))且e與ψ(n)最大公約數(shù)為1即?e與t互質(zhì)
}?while?((this.e?>=?this.t)?||?(this.gcd(this.t?this.e)?!=?1));
System.out.println(“生成的公鑰為:“?+?“(“?+?this.n?+?““?+?this.e?+?“)“);
}

//?生成私鑰?e*d=1(modψ(n))==>?d?=?(kψ(n)+1)?/?e
public?void?getPrivate_key()?{
long?value?=?1;?//?value?是e和d的乘積
outer:?for?(long?k?=?1;;?k++)?{
value?=?k?*?this.t?+?1;
if?((value?%?this.e?==?0))?{
this.d?=?value?/?this.e;
break?outer;
}
}
System.out.println(“產(chǎn)生的一個私鑰為:“?+?“(“?+?this.n?+?““?+?this.d?+?“)“);
System.out.println(“私鑰d的值為:“?+?this.d);
}

//?輸入明文
public?void?getText()?throws?Exception?{
System.out.println(“請輸入明文:“);
BufferedReader?stdin?=?new?BufferedReader(new?InputStreamReader(
System.in));
mc?=?stdin.readLine();

}

//?解密密文
public?void?pascolum()?throws?Exception?{
this.getText();
System.out.println(“輸入明文為:?“?+?this.mc);
//?加密
ArrayList?cestr?=?new?ArrayList();
for?(int?i?=?0;?i? this.c?=?this.colum((long)?mc.charAt(i)?this.n?this.e);
cestr.add(c);
}
System.out.println(“加密后所得的密文為:“?+?cestr);
//?解密
StringBuffer?destr?=?new?StringBuffer();
for?(int?j?=?0;?j? this.word?=?this.colum(Long.parseLong(cestr.get(j).toString())
this.n?this.d);
destr.append((char)?word);
}
System.out.println(“解密后所得的明文為:“?+?destr);

}

//?加密、解密計算
public?long?colum(long?mc?long?n?long?key)?{
BigInteger?bigy?=?new?BigInteger(String.valueOf(mc));
BigInteger?bign?=?new?BigInteger(String.valueOf(n));
BigI

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\
?????文件???????????0??2016-07-28?17:27??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.lock
?????文件???????42583??2017-01-05?11:27??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.log
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\.taskListIndex\
?????文件??????????20??2016-09-07?10:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\.taskListIndex\segments.gen
?????文件??????????32??2016-09-07?10:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\.taskListIndex\segments_1
?????文件?????????250??2016-12-15?15:34??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\.tasks.xml.zip
?????文件?????????438??2016-07-28?17:28??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\repositories.xml.zip
?????文件?????????250??2016-12-15?15:54??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.mylyn\tasks.xml.zip
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.compare\
?????文件?????????456??2016-11-26?17:13??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.compare\dialog_settings.xml
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\52\
?????文件????????6699??2016-12-15?00:15??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\52\d0995db618c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\54\
?????文件????????6776??2016-12-15?00:07??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\54\f022188b17c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?21:11??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\71\
?????文件???????????0??2016-12-15?00:26??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\71\708468061ac200161d29fa5deb783ab7
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\8\
?????文件????????6195??2016-12-15?00:08??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\8\a083443e18c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\82\
?????文件????????5642??2016-12-14?18:25??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\82\90a4735516c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\8f\
?????文件????????6689??2016-12-15?00:16??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\8f\f020b12e19c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\95\
?????文件????????6002??2016-12-14?23:59??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\95\c0bec31e17c20016156fd64fd818ae61
?????目錄???????????0??2017-09-26?19:57??RSA數(shù)字簽名算法的具體實現(xiàn)\.metadata\.plugins\org.eclipse.core.resources\.history\b8\
............此處省略305個文件信息

評論

共有 條評論