Generate Trigger Numbers
In ElGamal fruit numbers are 2 triggers, namely g and k. both must be excellent and worth less than the range of data or p. Numbers g are constants or fixed. So in this final project in the initial g value 13. The value of k is a variable or change 1 change for each plain text character.
In this final project in the form k do in a class GenerateK. Program listing is
public class GenerateK {
double kb ; double kx = 0;
public double setK (){ int prima =0;
while(prima == 0){
kx = (Math.random()*221)+1; prima = cekprima (kx); } return kx; }
public double getK (){
kb = setK(); return kb; }
private static int cekprima(double ky){
int ky1 = (int)ky; int sip =1;
int batas = (int) Math.ceil(ky/2);
if((ky1==1)||(ky1==2)){
sip=1;}
else{
for(int i=2;i <= batas;i++){
int tes = ky1 % i;
if(tes==0){sip = 0; break;}
else sip =1;} }
return sip;}}
To get the number k, after GenerateK create a new object, do the calling method getK (). The following example program listing:
GenerateK bikink = new GenerateK ();
double kd = Math.ceil(bikink.getK());
int k = (int) kd - 1;
in decrypt and encrypt process you can lean more in the file download
8 comments:
oke thanks, tak pelajari dulu nanti kalau da apa2 mohon bantuannya???
thanks gan...ntar kalo ada butuh teori atau listing aku post saja disini...kalo bisa follow blogq ini gan biar informasinya cepet nyampek ke kamu
mas aku padahal diminta pak idris buat seperti ini ::::
ada plain = "aku bisa elgamal"
muncul chiper = ZZZZZZZZZZZZZ
tanpa gui.
kemarin script coba smpyan tak utek-utek malah gak karuan kabeh....
mas...sampeyan wes download file projectku tah??? download ae...kalo masih belum bisa...ntar ketemu aku langsung aja..oke??
mas aku dah download semua ,gini aku diminta merubah file coba punya smpyan,disitu kan menggunakan gui aku diminta merubah jadi konsol aja tidak ada inputan.
seperti aku deklarasikan string s = "elgamal"
ya munculnya
ini plaintext = elgamal
ini chipertext = .......
mas kapan ke its ....
mas kalau online jam berapa ???
sering ku telp mas tapi gak da yang angkat. thanks
bro,,udah ju kasih kan ke pak idris
Trima kasih banget mas buat source codenya.
oke,, salam kenal Yoso Adi dari Bandung ITT Bandung :)
oke yastasha.........sama sama
Post a Comment