Search This Blog

Tuesday, February 2, 2010

Simulation of ElGamal Cryptography

The following are examples of simulation programs ElGamal cryptography. This program is made with JAVA programming language, and its design interface with Net bean. You can download the project files (Indonesian version) here. click here to download

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;}}

call class is conducted generateK random integer value between 1 and 222. Then the numbers k will be test in prime testing. Prime test is testing whether an integer k prime or not, by way Modulo operations with numbers number k 2 to k \ 2. If the modulation is always not equal to zero, k can be considered prime. But if one Modulo operations produce zero, k is not prime. If it does not fit the random re-done to produce a prime k.
To get the number k, after GenerateK create a new object, do the calling method getK (). The following example program listing:


800x600

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:

tonos said...

oke thanks, tak pelajari dulu nanti kalau da apa2 mohon bantuannya???

Icank said...

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

tonos said...

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....

Icank said...

mas...sampeyan wes download file projectku tah??? download ae...kalo masih belum bisa...ntar ketemu aku langsung aja..oke??

tonos said...

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

Icank said...

bro,,udah ju kasih kan ke pak idris

yAst@haA said...

Trima kasih banget mas buat source codenya.

oke,, salam kenal Yoso Adi dari Bandung ITT Bandung :)

Icank said...

oke yastasha.........sama sama

Calendar