Lampiran 1.
DAFTAR PUBLIKASI ILMIAH PENULIS (TESIS)
No. Judul Artikel Penulis Publikasi (Seminar/Jurnal,
dll)
Waktu publikasi
Tempat
1 Kombinasi Algoritma AES, RC4 dan Elgamal Dalam Skema Hybrid untuk Keamanan Data
Adi Widarma
Journal of Computer Engineering, System and Sains Vol 1 No 1 2016.
Februari 2016
Lampiran 2.
Listing Program enkripsi dan dekripsi AES <?php
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * MIX COLUMN
DIMULAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*
* GALOIS FIELD ALGORITHM BEGIN */
function SumL($hexa,$hexb){ $hexc='ff';
$deca=hexdec($hexa); $decb=hexdec($hexb); $decc=hexdec($hexc);
$result1=dechex($deca+$decb); if(strlen($result1)==3){
$tempresult=dechex($deca+$decb-$decc); if(strlen($tempresult)==1){
$L='0'.$tempresult; }
else{
$L=$tempresult; }
} else{
if(strlen($result1)==1){ $L='0'.$result1;
} else{
$L=$result1; }
}
return $L; }
///////////////////////////////////////////////////////// //////////////////////////////////////////////////////// function hexnumconverter($hex){
$i=$hex;
if($i=='a'){
elseif($i=='b'){ $numconv='11'; }
elseif($i=='c'){ $numconv='12'; }
elseif($i=='d'){ $numconv='13'; }
elseif($i=='e'){ $numconv='14'; }
elseif($i=='f'){ $numconv='15'; }
else{
$numconv=$i; }
return $numconv; }
///////////////////////////////////////////////////////// //////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////////// function numhexconverter($num){
$i=$num;
if($i=='10'){
$hexconv='a'; }
elseif($i=='11'){ $hexconv='b'; }
elseif($i=='12'){ $hexconv='c'; }
elseif($i=='13'){ $hexconv='d'; }
elseif($i=='14'){ $hexconv='e'; }
elseif($i=='15'){ $hexconv='f'; }
else{
$hexconv=$i; }
}
///////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
function Laritmathic($hex){
$Lhex1=hexnumconverter($hex[0]); $Lhex2=hexnumconverter($hex[1]); $LT[0]=array('
','00','19','01','32','02','1a','c6','4b','c7','1b','68', '33','ee','df','03');
$LT[1]=array('64','04','e0','0e','34','8d','81','ef','4c' ,'71','08','c8','f8','69','1c','c1');
$LT[2]=array('7d','c2','1d','b5','f9','b9','27','6a','4d' ,'e4','a6','72','9a','c9','09','78');
$LT[3]=array('65','2f','8a','05','21','0f','e1','24','12' ,'f0','82','45','35','93','da','8e');
$LT[4]=array('96','8f','db','bd','36','d0','ce','94','13' ,'5c','d2','f1','40','46','83','38');
$LT[5]=array('66','dd','fd','30','bf','06','8b','62','b3' ,'25','e2','98','22','88','91','10');
$LT[6]=array('7e','6e','48','c3','a3','b6','1e','42','3a' ,'6b','28','54','fa','85','3d','ba');
$LT[7]=array('2b','79','0a','15','9b','9f','5e','ca','4e' ,'d4','ac','e5','f3','73','a7','57');
$LT[8]=array('af','58','a8','50','f4','ea','d6','74','4f' ,'ae','e9','d5','e7','e6','ad','e8');
$LT[9]=array('2c','d7','75','7a','eb','16','0b','f5','59' ,'cb','5f','b0','9c','a9','51','a0');
$LT[10]=array('7f','0c','f6','6f','17','c4','49','ec','d8 ','43','1f','2d','a4','76','7b','b7');
$LT[11]=array('cc','bb','3e','5a','fb','60','b1','86','3b ','52','a1','6c','aa','55','29','9d');
$LT[12]=array('97','b2','87','90','61','be','dc','fc','bc ','95','cf','cd','37','3f','5b','d1');
$LT[14]=array('44','11','92','d9','23','20','2e','89','b4 ','7c','b8','26','77','99','e3','a5');
$LT[15]=array('67','4a','ed','de','c5','31','fe','18','0d ','63','8c','80','c0','f7','70','07');
$hexL=$LT[$Lhex1][$Lhex2]; return $hexL;
}
function Earitmathic($hex){
$Ehex1=hexnumconverter($hex[0]); $Ehex2=hexnumconverter($hex[1]);
$ET[0]=array('01','03','05','0f','11','33','55','ff','1a' ,'2e','72','96','a1','f8','13','35');
$ET[1]=array('5f','e1','38','48','d8','73','95','a4','f7' ,'02','06','0a','1e','22','66','aa');
$ET[2]=array('e5','34','5c','e4','37','59','eb','26','6a' ,'be','d9','70','90','ab','e6','31');
$ET[3]=array('53','f5','04','0c','14','3c','44','cc','4f' ,'d1','68','b8','d3','6e','b2','cd');
$ET[4]=array('4c','d4','67','a9','e0','3b','4d','d7','62' ,'a6','f1','08','18','28','78','88');
$ET[5]=array('83','9e','b9','d0','6b','bd','dc','7f','81' ,'98','b3','ce','49','db','76','9a');
$ET[6]=array('b5','c4','57','f9','10','30','50','f0','0b' ,'1d','27','69','bb','d6','61','a3');
$ET[7]=array('fe','19','2b','7d','87','92','ad','ec','2f' ,'71','93','ae','e9','20','60','a0');
$ET[8]=array('fb','16','3a','4e','d2','6d','b7','c2','5d' ,'e7','32','56','fa','15','3f','41');
$ET[9]=array('c3','5e','e2','3d','47','c9','40','c0','5b' ,'ed','2c','74','9c','bf','da','75');
$ET[10]=array('9f','ba','d5','64','ac','ef','2a','7e','82 ','9d','bc','df','7a','8e','89','80');
$ET[12]=array('fc','1f','21','63','a5','f4','07','09','1b ','2d','77','99','b0','cb','46','ca');
$ET[13]=array('45','cf','4a','de','79','8b','86','91','a8 ','e3','3e','42','c6','51','f3','0e');
$ET[14]=array('12','36','5a','ee','29','7b','8d','8c','8f ','8a','85','94','a7','f2','0d','17');
$ET[15]=array('39','4b','dd','7c','84','97','a2','fd','1c ','24','6c','b4','c7','52','f6','01');
$hexE=$ET[$Ehex1][$Ehex2]; return $hexE;
}
///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////
function GaloisField($hex1,$hex2){
$GF=Earitmathic(SumL(Laritmathic($hex1),Laritmathic($hex2 )));
return $GF; }
/*
* GALOIS FIELD ALGORITHM END */
function xored($bitfirst,$bitsecond) {
$byk=strlen($bitfirst); for ($i=0; $i <$byk; $i++) {
if($bitfirst[$i]==$bitsecond[$i]){ $xored2=$xored2.'0';
} else{
$xored2=$xored2.'1'; }
}
return $xored2; }
function unxored($arr, $arr2) {
$byk=strlen($arr);
for ($i=0;$i<$byk;$i++) {
if($arr2[$i]=='0'){
else {
if($arr[$i]=='0') {
$xored1=$xored1.'1'; }
else {
$xored1=$xored1.'0'; }
} }
return $xored1; }
function Binconverter($hex){ include 'binclass.php'; if($hex[0]=='a'){
$digL=$binary[10]; }
elseif($hex[0]=='b'){ $digL=$binary[11]; }
elseif($hex[0]=='c'){ $digL=$binary[12]; }
elseif($hex[0]=='d'){ $digL=$binary[13]; }
elseif($hex[0]=='e'){ $digL=$binary[14]; }
elseif($hex[0]=='f'){ $digL=$binary[15]; }
else{
$digL=$binary[$hex[0]]; }
if($hex[1]=='a'){
$digR=$binary[10]; }
elseif($hex[1]=='b'){ $digR=$binary[11]; }
elseif($hex[1]=='c'){ $digR=$binary[12]; }
elseif($hex[1]=='d'){ $digR=$binary[13]; }
$digR=$binary[14]; }
elseif($hex[1]=='f'){ $digR=$binary[15]; }
else{
$digR=$binary[$hex[1]]; }
$binconv=$digL.$digR; return $binconv;
}
function Hexconverter($bin){ include 'binclass.php';
$binsplit=str_split($bin,4); for($i=0;$i<16;$i++){
if($binsplit[0]==$binary[$i]){ if($i=='10'){
$digL='a'; }
elseif($i=='11'){ $digL='b'; }
elseif($i=='12'){ $digL='c'; }
elseif($i=='13'){ $digL='d'; }
elseif($i=='14'){ $digL='e'; }
elseif($i=='15'){ $digL='f'; }
else{
$digL=$i; }
}
if($binsplit[1]==$binary[$i]){ if($i=='10'){
$digR='a'; }
elseif($i=='11'){ $digR='b'; }
elseif($i=='12'){ $digR='c'; }
}
elseif($i=='14'){ $digR='e'; }
elseif($i=='15'){ $digR='f'; }
else{
$digR=$i; }
} }
$hexconv=$digL.$digR; return $hexconv;
}
function Tempmixcolumn($matrixplain){ $mix0=array('02','03','01','01'); $mix1=array('01','02','03','01'); $mix2=array('01','01','02','03'); $mix3=array('03','01','01','02'); $j=1;
for($i=0;$i<4;$i++){
$hex2num=$matrixplain[2*$i].$matrixplain[2*$i+1]; $GF0[$i]=GaloisField($hex2num,$mix0[$i]);
$GF1[$i]=GaloisField($hex2num,$mix1[$i]); $GF2[$i]=GaloisField($hex2num,$mix2[$i]); $GF3[$i]=GaloisField($hex2num,$mix3[$i]); }
$hex0=Hexconverter(xored(xored(xored(Binconverter($GF0[0] ),Binconverter($GF0[1])),Binconverter($GF0[2])),Binconver ter($GF0[3])));
$hex1=Hexconverter(xored(xored(xored(Binconverter($GF1[0] ),Binconverter($GF1[1])),Binconverter($GF1[2])),Binconver ter($GF1[3])));
$hex2=Hexconverter(xored(xored(xored(Binconverter($GF2[0] ),Binconverter($GF2[1])),Binconverter($GF2[2])),Binconver ter($GF2[3])));
$hex3=Hexconverter(xored(xored(xored(Binconverter($GF3[0] ),Binconverter($GF3[1])),Binconverter($GF3[2])),Binconver ter($GF3[3])));
$colect=$hex0.$hex1.$hex2.$hex3; return $colect;
}
if($j%8==6){
$mx4=$mx4.$hex[$j].$hex[$j+1]; }
elseif($j%8==0) {
$mx1=$mx1.$hex[$j].$hex[$j+1]; }
elseif($j%8==2){
$mx2=$mx2.$hex[$j].$hex[$j+1]; }
elseif($j%8==4){
$mx3=$mx3.$hex[$j].$hex[$j+1]; }
}
$ChiperMX=Tempmixcolumn($mx1).Tempmixcolumn($mx2).Tempmix column($mx3).Tempmixcolumn($mx4);
// Menyusun ulang susunan $mx1='';
$mx2=''; $mx3=''; $mx4='';
for($j=0;$j<32;$j++){ if($j%8==6){
$mx4=$mx4.$hex[$j].$hex[$j+1]; }
elseif($j%8==0) {
$mx1=$mx1.$hex[$j].$hex[$j+1]; }
elseif($j%8==2){
$mx2=$mx2.$hex[$j].$hex[$j+1]; }
elseif($j%8==4){
$mx3=$mx3.$hex[$j].$hex[$j+1]; }
}
$get=$mx1.$mx2.$mx3.$mx4; return $get;
}
function Tempinvmixcolumn($matrixchiper){ $unmix0=array('0e','0b','0d','09'); $unmix1=array('09','0e','0b','0d'); $unmix2=array('0d','09','0e','0b'); $unmix3=array('0b','0d','09','0e'); $j=1;
for($i=0;$i<4;$i++){
$hex2num=$matrixchiper[2*$i].$matrixchiper[2*$i+1]; $GF0[$i]=GaloisField($hex2num,$unmix0[$i]);
}
$unhex0=Hexconverter(xored(xored(xored(Binconverter($GF0[ 0]),Binconverter($GF0[1])),Binconverter($GF0[2])),Binconv erter($GF0[3])));
$unhex1=Hexconverter(xored(xored(xored(Binconverter($GF1[ 0]),Binconverter($GF1[1])),Binconverter($GF1[2])),Binconv erter($GF1[3])));
$unhex2=Hexconverter(xored(xored(xored(Binconverter($GF2[ 0]),Binconverter($GF2[1])),Binconverter($GF2[2])),Binconv erter($GF2[3])));
$unhex3=Hexconverter(xored(xored(xored(Binconverter($GF3[ 0]),Binconverter($GF3[1])),Binconverter($GF3[2])),Binconv erter($GF3[3])));
$colect=$unhex0.$unhex1.$unhex2.$unhex3; return $colect;
}
function invmixcolumn($hex){ for($j=0;$j<32;$j++){ if($j%8==6){
$mx4=$mx4.$hex[$j].$$hex[$j+1]; }
elseif($j%8==0) {
$mx1=$mx1.$hex[$j].$hex[$j+1]; }
elseif($j%8==2){
$mx2=$mx2.$$hex[$j].$hex[$j+1]; }
elseif($j%8==4){
$mx3=$mx3.$hex[$j].$hex[$j+1]; }
}
$ChiperMX=Tempinvmixcolumn($mx1).Tempinvmixcolumn($mx2).T empinvmixcolumn($mx3).Tempinvmixcolumn($mx4);
// Menyusun ulang susunan $mx1='';
$mx2=''; $mx3=''; $mx4='';
for($j=0;$j<32;$j++){ if($j%8==6){
$mx4=$mx4.$hex[$j].$hex[$j+1]; }
elseif($j%8==0) {
elseif($j%8==2){
$mx2=$mx2.$hex[$j].$hex[$j+1]; }
elseif($j%8==4){
$mx3=$mx3.$hex[$j].$hex[$j+1]; }
}
$get=$mx1.$mx2.$mx3.$mx4; return $get;
}
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * MIX COLUMN
SELSESAI///////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * SUBBYTES
BEGINNING//////////////////////////////////////////////// ///////////////////////////////////////////////////////// ////////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function SBOX($hex){
$SBhex1=hexnumconverter($hex[0]); $SBhex2=hexnumconverter($hex[1]);
$SB[0]=array('63','7c','77','7b','f2','6b','6f','c5','30' ,'01','67','2b','fe','d7','ab','76');
$SB[1]=array('ca','82','c9','7d','fa','59','47','f0','ad' ,'d4','a2','af','9c','a4','72','c0');
$SB[2]=array('b7','fd','93','26','36','3f','f7','cc','34' ,'a5','e5','f1','71','d8','31','15');
$SB[3]=array('04','c7','23','c3','18','96','05','9a','07' ,'12','80','e2','eb','27','b2','75');
$SB[5]=array('53','d1','00','ed','20','fc','b1','5b','6a' ,'cb','be','39','4a','4c','58','cf');
$SB[6]=array('d0','ef','aa','fb','43','4d','33','85','45' ,'f9','02','7f','50','3c','9f','a8');
$SB[7]=array('51','a3','40','8f','92','9d','38','f5','bc' ,'b6','da','21','10','ff','f3','d2');
$SB[8]=array('cd','0c','13','ec','5f','97','44','17','c4' ,'a7','7e','3d','64','5d','19','73');
$SB[9]=array('60','81','4f','dc','22','2a','90','88','46' ,'ee','b8','14','de','5e','0b','db');
$SB[10]=array('e0','32','3a','0a','49','06','24','5c','c2 ','d3','ac','62','91','95','e4','79');
$SB[11]=array('e7','c8','37','6d','8d','d5','4e','a9','6c ','56','f4','ea','65','7a','ae','08');
$SB[12]=array('ba','78','25','2e','1c','a6','b4','c6','e8 ','dd','74','1f','4b','bd','8b','8a');
$SB[13]=array('70','3e','b5','66','48','03','f6','0e','61 ','35','57','b9','86','c1','1d','9e');
$SB[14]=array('e1','f8','98','11','69','d9','8e','94','9b ','1e','87','e9','ce','55','28','df');
$SB[15]=array('8c','a1','89','0d','bf','e6','42','68','41 ','99','2d','0f','b0','54','bb','16');
$hexSB=$SB[$SBhex1][$SBhex2]; return $hexSB;
}
function InvSBOX($hex){
$INVSB[0]=array('63','7c','77','7b','f2','6b','6f','c5',' 30','01','67','2b','fe','d7','ab','76');
$INVSB[1]=array('ca','82','c9','7d','fa','59','47','f0',' ad','d4','a2','af','9c','a4','72','c0');
$INVSB[2]=array('b7','fd','93','26','36','3f','f7','cc',' 34','a5','e5','f1','71','d8','31','15');
$INVSB[4]=array('09','83','2c','1a','1b','6e','5a','a0',' 52','3b','d6','b3','29','e3','2f','84');
$INVSB[5]=array('53','d1','00','ed','20','fc','b1','5b',' 6a','cb','be','39','4a','4c','58','cf');
$INVSB[6]=array('d0','ef','aa','fb','43','4d','33','85',' 45','f9','02','7f','50','3c','9f','a8');
$INVSB[7]=array('51','a3','40','8f','92','9d','38','f5',' bc','b6','da','21','10','ff','f3','d2');
$INVSB[8]=array('cd','0c','13','ec','5f','97','44','17',' c4','a7','7e','3d','64','5d','19','73');
$INVSB[9]=array('60','81','4f','dc','22','2a','90','88',' 46','ee','b8','14','de','5e','0b','db');
$INVSB[10]=array('e0','32','3a','0a','49','06','24','5c', 'c2','d3','ac','62','91','95','e4','79');
$INVSB[11]=array('e7','c8','37','6d','8d','d5','4e','a9', '6c','56','f4','ea','65','7a','ae','08');
$INVSB[12]=array('ba','78','25','2e','1c','a6','b4','c6', 'e8','dd','74','1f','4b','bd','8b','8a');
$INVSB[13]=array('70','3e','b5','66','48','03','f6','0e', '61','35','57','b9','86','c1','1d','9e');
$INVSB[14]=array('e1','f8','98','11','69','d9','8e','94', '9b','1e','87','e9','ce','55','28','df');
$INVSB[15]=array('8c','a1','89','0d','bf','e6','42','68', '41','99','2d','0f','b0','54','bb','16');
for($i=0;$i<16;$i++){
for($j=0;$j<16;$j++){
if($INVSB[$i][$j]==$hex){
$hexa=numhexconverter($i); $hexb=numhexconverter($j); }
} }
$hexINVSB=$hexa.$hexb; return $hexINVSB;
}
if($i%2==0){
$hexcandidat=$subhex[$i].$subhex[$i+1]; $subb=$subb.SBOX($hexcandidat);
} }
$get=$subb; return $get; }
function InvSubBytes($subhex){ for($i=0;$i<32;$i++){
if($i%2==0){
$hexcandidat=$subhex[$i].$subhex[$i+1]; $invsubb=$invsubb.InvSBOX($hexcandidat); }
}
$get=$invsubb; return $get; }
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * SUBBYTES
SELESAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * SIFTROWS
MULAI//////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function Siftrows($hex){
$splithex=str_split($hex,8); for($a=0;$a<8;$a++){
if($a>1){
$hex1=$hex1.$splithex[1][$a]; }
if($a>3){
$hex2=$hex2.$splithex[2][$a]; }
$hex3=$hex3.$splithex[3][$a]; }
}
$hex1=$hex1.$splithex[1][0].$splithex[1][1];
$hex2=$hex2.$splithex[2][0].$splithex[2][1].$splithex[2][ 2].$splithex[2][3];
$hex3=$splithex[3][6].$splithex[3][7].$hex3; $get=$splithex[0].$hex1.$hex2.$hex3;
return $get; }
function InvSiftrows($hex){
$splithex=str_split($hex,8); for($a=0;$a<8;$a++){
if($a>1){
$hex3=$hex3.$splithex[3][$a]; }
if($a>3){
$hex2=$hex2.$splithex[2][$a]; }
if($a<6){
$hex1=$hex1.$splithex[1][$a]; }
}
$hex1=$splithex[1][6].$splithex[1][7].$hex1;
$hex2=$hex2.$splithex[2][0].$splithex[2][1].$splithex[2][ 2].$splithex[2][3];
$hex3=$hex3.$splithex[3][0].$splithex[3][1]; $get=$splithex[0].$hex1.$hex2.$hex3;
return $get; }
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * SIFTROWS
SELESAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * ROUNDKEY
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function KeySchedule($hexkey){ $RoundKey[0]=$hexkey;
$Rcon[1]='01000000'; $Rcon[2]='02000000'; $Rcon[3]='04000000'; $Rcon[4]='08000000'; $Rcon[5]='10000000'; $Rcon[6]='20000000'; $Rcon[7]='40000000'; $Rcon[8]='80000000'; $Rcon[9]='1b000000'; $Rcon[10]='36000000'; for($i=1;$i<=10;$i++){
for($j=0;$j<32;$j++){ if($j%8==6){
$hex4=$hex4.$RoundKey[$i-1][$j].$RoundKey[$i-1][$j+1];
}
elseif($j%8==0) {
$hex1=$hex1.$RoundKey[$i-1][$j].$RoundKey[$i-1][$j+1];
}
elseif($j%8==2){
$hex2=$hex2.$RoundKey[$i-1][$j].$RoundKey[$i-1][$j+1];
}
elseif($j%8==4){
$hex3=$hex3.$RoundKey[$i-1][$j].$RoundKey[$i-1][$j+1];
} }
// Rotasi HEX4 DARI 1 KE 4
for($j=0;$j<8;$j++){ if($j>1){
$hex4R=$hex4R.$hex4[$j]; }
}
$hex4Rotasi=$hex4R.$hex4[0].$hex4[1]; // SubBytes $hex4Rotasi
for($j=0;$j<8;$j++){ if($j%2==0){
$hex4SB=$hex4SB.SubBytes($hex4Rotasi[$j].$hex4Rotasi[$j+1 ]);
}
//HEX1 XOR HEX4SB XOR RCON DLL for($j=0;$j<8;$j++){
if($j%2==0){
$can1=$can1.Hexconverter(xored(xored(Binconverter($hex1[$ j].$hex1[$j+1]),Binconverter($hex4SB[$j].$hex4SB[$j+1])), Binconverter($Rcon[$i][$j].$Rcon[$i][$j+1])));
} }
for($j=0;$j<8;$j++){ if($j%2==0){
$can2=$can2.Hexconverter(xored(Binconverter($hex2[$j].$he x2[$j+1]),Binconverter($can1[$j].$can1[$j+1])));
} }
for($j=0;$j<8;$j++){ if($j%2==0){
$can3=$can3.Hexconverter(xored(Binconverter($hex3[$j].$he x3[$j+1]),Binconverter($can2[$j].$can2[$j+1])));
} }
for($j=0;$j<8;$j++){ if($j%2==0){
$can4=$can4.Hexconverter(xored(Binconverter($hex4[$j].$he x4[$j+1]),Binconverter($can3[$j].$can3[$j+1])));
} }
// Menyusun ulang susunan
$cand=$can1.$can2.$can3.$can4; for($j=0;$j<8;$j++){
if($j%2==0){
$RoundK=$RoundK.$cand[$j].$cand[$j+1].$cand[$j+8].$cand[$ j+8+1].$cand[$j+8+8].$cand[$j+8+8+1].$cand[$j+8+8+8].$can d[$j+8+8+8+1];
} }
$RoundKey[$i]=$RoundK; // REPRODUKSI KEY BARU $hex1='';
$hex2=''; $hex3=''; $hex4=''; $hex4R='';
$can1=''; $can2=''; $can3=''; $can4=''; $cand=''; $RoundK=''; }
//echo $can1; return $RoundKey; }
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// * ROUNDKEY
SELESAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// *ENCRYPT AES
DIMULAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function AESENCRYPT($PlainText,$Kunci){
//Terjemah PlainText dan Kunci Ke HExadexcimal for($j=0;$j<16;$j++){
$PlainHex=$PlainHex.bin2hex($PlainText[$j]); $KeyHex=$KeyHex.bin2hex($Kunci[$j]);
}
// KeyHex Masuk Ke Tahap Key Schedule $Key=KeySchedule($KeyHex);
// XOR addROUNDKEY0 for($j=0;$j<32;$j++){ if($j%2==0){
} }
// ENCHIPERING DIMULAI for($i=1;$i<=9;$i++){ // SUBBYTES
$ChiperSB[$i]=SubBytes($ChiperHex[$i-1]); // SIFTROWS
$ChiperSF[$i]=Siftrows($ChiperSB[$i]); // MIXKOLOM
$ChiperMXC[$i]= mixcolumn($ChiperSF[$i]);
// XOR addROUNDKEY for($q=0;$q<32;$q++){ if($q%2==0){
$ChiperXOR[$i]=$ChiperXOR[$i].Hexconverter(xored(Binconve rter($ChiperMXC[$i][$q].$ChiperMXC[$i][$q+1]),Binconverte r($Key[$i][$q].$Key[$i][$q+1])));
} }
$ChiperHex[$i]=$ChiperXOR[$i]; $mx1='';
$mx2=''; $mx3=''; $mx4='';
$ChiperMX='';
$ChiperMXC[$i]=''; $ChiperXOR[$i]=''; }
// ENCHIPERING TERAKHIR // SUBBYTES
$ChiperSB[10]=SubBytes($ChiperHex[9]); // SIFTROWS
$ChiperSF[10]=Siftrows($ChiperSB[10]); // XOR addROUNDKE10
for($j=0;$j<32;$j++){ if($j%2==0){
$ChiperHex[10]=$ChiperHex[10].Hexconverter(xored(Binconve rter($ChiperSF[10][$j].$ChiperSF[10][$j+1]),Binconverter( $Key[10][$j].$Key[10][$j+1])));
} }
$CHIPERTEXT=abjadconverter($ChiperHex[10]); return $CHIPERTEXT;
}
*ENCRYPT AES
SELESAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// *DECRYPT AES
DIMULAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function AESDECRYPT($ChiperText,$Kunci){
//Terjemah PlainText dan Kunci Ke HExadexcimal for($j=0;$j<16;$j++){
$KeyHex=$KeyHex.bin2hex($Kunci[$j]);
$PlainHex=$PlainHex.bin2hex($ChiperText[$j]); }
$PlainHexA[10]=$PlainHex;
// KeyHex Masuk Ke Tahap Key Schedule $Key=KeySchedule($KeyHex);
//XOR addROUNDKE10 for($j=0;$j<32;$j++){ if($j%2==0){
$PlainSF[10]=$PlainSF[10].Hexconverter(unxored(Binconvert er($PlainHexA[10][$j].$PlainHexA[10][$j+1]),Binconverter( $Key[10][$j].$Key[10][$j+1])));
} }
// INVSIFTROWS
$PlainSF[10]=invSiftrows($PlainSF[10]); // INVSUBBYTES
$PlainSB[10]=InvSubBytes($PlainSF[10]); $PlainHexA[9]=$PlainSB[10];
// MULAI ENPLAINING for($i=9;$i>=1;$i--){
// UNXOR addROUNDKEY for($q=0;$q<32;$q++){ if($q%2==0){
rter($PlainHexA[$i][$q].$PlainHexA[$i][$q+1]),Binconverte r($Key[$i][$q].$Key[$i][$q+1])));
} }
// UNMIXKOLOM
$PlainMXC[$i]=invmixcolumn($PlainXOR[$i]); // UNSIFTROWS
$PlainSF[$i]=invSiftrows($PlainMXC[$i]); // UNSUBBYTES
$PlainSB[$i]=InvSubBytes($PlainSF[$i]); // Eksekusi
$PlainHexA[$i-1]=$PlainSB[$i]; $unmx1='';
$unmx2=''; $unmx3=''; $unmx4=''; $PlainMX='';
$PlainMXC[$i]=''; $PlainXOR[$i]=''; }
for($j=0;$j<32;$j++){ if($j%2==0){
$PlainHexAB[0]=$PlainHexAB[0].Hexconverter(unxored(Bincon verter($PlainHexA[0][$j].$PlainHexA[0][$j+1]),Binconverte r($Key[0][$j].$Key[0][$j+1])));
} }
$PLAINTETXT=abjadconverter($PlainHexAB[0]); return $PLAINTETXT;
}
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// *DECRYPT AES
SELESAI////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
/*/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// //////////////////////////////////////////////////// *HURUF
///////////////////////////////////////////////////////// ////////////////////////////////////////
*//////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////
function abjadconverter($hex){
for($j=0;$j<strlen($hex);$j++){ if($j%2==0){
$abjad=$abjad.hex2bin($hex[$j].$hex[$j+1]); }
}
return $abjad; }
/*
* STRING AES BANYAK DATA DIMULAI */
function ALLSTRAESENC($plaintext,$Kunci){ $Panjangdata=strlen($plaintext);
$sisa=$Panjangdata%16; $jlhtambahan=16-$sisa; if($sisa==0){
$jlhloop=(($Panjangdata-$sisa)/16); $plainenc=str_split($plaintext,16); //ALLAESENCRIPTION
for($j=0;$j<$jlhloop;$j++){
$CHIPER=$CHIPER.AESENCRYPT($plainenc[$j],$Kunci); }
} else{
$jlhloop=(($Panjangdata-$sisa)/16)+1; $plainenc=str_split($plaintext,16); //JUMLAH TAMBAHAN DATA STRING TERAKHIR for($i=0;$i<$jlhtambahan;$i++){
$plainenc[$jlhloop-1]=$plainenc[$jlhloop-1].hex2bin('fe');
}
//ALLAESENCRIPTION
for($j=0;$j<$jlhloop;$j++){
$CHIPER=$CHIPER.AESENCRYPT($plainenc[$j],$Kunci); }
}
return $CHIPER; }
function ALLSTRAESDEC($chipertext,$Kunci){ $Panjangdata=strlen($chipertext);
$jlhloop=($Panjangdata)/16;
//ALLAESENCRIPTION
for($j=0;$j<$jlhloop;$j++){
$PLAIN=$PLAIN.AESDECRYPT($plaindec[$j],$Kunci); }
//SORTIR HEX fe $PLAINSEJATI=
str_replace(hex2bin('fe'),'',$PLAIN); return $PLAINSEJATI;
}
//$a=ALLSTRAESENC('TESIS ADIWIDARMA','S2INFORMATIKAUSU'); //$b=ALLSTRAESDEC($a,'S2INFORMATIKAUSU');
/*
* STRING AES BANYAK DATA SELESAI */
//echo hex2bin('fd');
//$a= AESENCRYPT('TESIS ADIWIDARMA','S2INFORMATIKAUSU'); //$b= AESDECRYPT($a,'S2INFORMATIKAUSU');
//echo $a.'<br/>'.$b; //session_start(); //$_SESSION['aesdec'];
//echo $_SESSION['aesenc'].'<br/>'; //echo $_SESSION['rc4enc'].'<br/>'; //echo $_SESSION['kunci1'].'<br/>'; //echo $_SESSION['kunci2'].'<br/>';
//echo '<textarea id="area" name="textrevaes" placeholder="Tulis Pesan"
id="txtrev">'.$_SESSION['aes'].'</textarea>'; //echo hex2bin('fe');
?>
Listing Program enkripsi dan dekripsi RC4 <?php
function encRC4($plain,$key){ for($i=0;$i<=255;$i++){
$T=$T.$key[$i%strlen($key)]; }
$j=0;
for($i=0;$i<=255;$i++){
$j=($j+$i+ord($T[$i]))%256; $S=$S.$j;
} $i=0; $j=0;
$plen=strlen($plain); while($plen>0){
$i=($i+1)%256;
$m=($S[$i]+$S[$j])%255; $K=$K.chr($m);
$plen=$plen-1; }
// convert Binary to xor
for($i=0;$i<strlen($K);$i++){
$BinHexad=BinHexaDetector(bin2hex($K[$i])); $BinPlain=BinHexaDetector(bin2hex($plain[$i])); $encbit=$encbit.xored($BinHexad,$BinPlain); }
$bitsplit=str_split($encbit,8); // convert to String
for($b=0;$b<strlen($K);$b++) {
$Chiper=$Chiper.hex2bin(HexaBinDetector($bitsplit[$b])); }
return $Chiper; }
function decRC4($Chiper,$key){ for($i=0;$i<=255;$i++){
$T=$T.$key[$i%strlen($key)]; }
$j=0;
for($i=0;$i<=255;$i++){
$j=($j+$i+ord($T[$i]))%256; $S=$S.$j;
} $i=0; $j=0;
$plen=strlen($Chiper); while($plen>0){
$i=($i+1)%256;
$j=($j+$S[$i]) %256; $m=($S[$i]+$S[$j])%255; $K=$K.chr($m);
$plen=$plen-1; }
// convert Binary and unxor for($i=0;$i<strlen($K);$i++){
$BinHexad=BinHexaDetector(bin2hex($K[$i]));
$BinChiper=BinHexaDetector(bin2hex($Chiper[$i])); $decbit=$decbit.unxored($BinHexad,$BinChiper); }
$bitsplit=str_split($decbit,8); // convert to String
for($b=0;$b<strlen($K);$b++) {
}
return $Plain; }
function xored($bitfirst,$bitsecond) {
$byk=strlen($bitfirst); for ($i=0; $i <$byk; $i++) {
if($bitfirst[$i]==$bitsecond[$i]){ $xored2=$xored2.'0';
} else{
$xored2=$xored2.'1'; }
}
return $xored2; }
function unxored($arr, $arr2) {
$byk=strlen($arr);
for ($i=0; $i <$byk; $i++) {
if($arr2[$i]=='0'){
$xored1=$xored1.$arr[$i]; }
else {
if($arr[$i]=='0') {
$xored1=$xored1.'1'; }
else {
$xored1=$xored1.'0'; }
} }
return $xored1; }
function BinHexaDetector($hex){ include 'binclass.php'; if($hex[0]=='a'){
$digL=$binary[10]; }
elseif($hex[0]=='b'){ $digL=$binary[11]; }
elseif($hex[0]=='d'){ $digL=$binary[13]; }
elseif($hex[0]=='e'){ $digL=$binary[14]; }
elseif($hex[0]=='f'){ $digL=$binary[15]; }
else{
$digL=$binary[$hex[0]]; }
if($hex[1]=='a'){
$digR=$binary[10]; }
elseif($hex[1]=='b'){ $digR=$binary[11]; }
elseif($hex[1]=='c'){ $digR=$binary[12]; }
elseif($hex[1]=='d'){ $digR=$binary[13]; }
elseif($hex[1]=='e'){ $digR=$binary[14]; }
elseif($hex[1]=='f'){ $digR=$binary[15]; }
else{
$digR=$binary[$hex[1]]; }
$binconv=$digL.$digR; return $binconv;
}
function HexaBinDetector($bin){ include 'binclass.php';
$binsplit=str_split($bin,4); for($i=0;$i<16;$i++){
if($binsplit[0]==$binary[$i]){ if($i=='10'){
$digL='a'; }
elseif($i=='11'){ $digL='b'; }
elseif($i=='13'){ $digL='d'; }
elseif($i=='14'){ $digL='e'; }
elseif($i=='15'){ $digL='f'; }
else{
$digL=$i; }
}
if($binsplit[1]==$binary[$i]){ if($i=='10'){
$digR='a'; }
elseif($i=='11'){ $digR='b'; }
elseif($i=='12'){ $digR='c'; }
elseif($i=='13'){ $digR='d'; }
elseif($i=='14'){ $digR='e'; }
elseif($i=='15'){ $digR='f'; }
else{
$digR=$i; }
} }
$hexconv=$digL.$digR; return $hexconv;
}
//$Q=encRC4('OYR','Bism'); //$L=decRC4($Q,'Bism'); //echo $Q.'<br/>';
//echo $L.'<br/>';
Listing program enkripsi dan dekripsi Elgamal <?php
/*
* ALGORITHMA ELGAMAL DIMULAI */
function KeyGenerator($P,$G,$X){ if($P<256){
if($G<$P-2 and $X<$P-2 and $X>=1){ $data[0]=1;
for ($i=0;$i<$X;$i++){ $rest[$i]=pow($G,1)%$P; if($data[$i]>$P) {
$data[$i+1]=($data[$i]*$rest[$i])%$P; }
else{
$data[$i+1]=($data[$i]*$rest[$i]); }
}
$y=$data[$X]%$P; }
else { $y=-2; }
} else{
$y=-1; }
return $y; }
function
oneenc($plainnumber,$mynumber,$yournumber,$P,$G){ $m=$plainnumber;
$k=$mynumber;
$y=KeyGenerator($P,$G,$yournumber); $data2[0]=1;
for ($i=0;$i<$k;$i++){
$rest2[$i]=pow($y,1)%$P; if($data2[$i]>$P) {
$data2[$i+1]=($data2[$i]*$rest2[$i])%$P; }
else{
$data2[$i+1]=($data2[$i]*$rest2[$i]); }
$a=$data2[$k]*$m%$P; return $a;
}
function onedec($encnumber,$mynumber,$yournumber,$P,$G){ $a=KeyGenerator($P, $G,$yournumber);
$b=$encnumber; $x=$mynumber; $data[0]=1;
for ($i=0;$i<$P-1-$x;$i++){
$rest[$i]=pow($a,1)%$P; if($data[$i]>$P) {
$data[$i+1]=($data[$i]*$rest[$i])%$P; }
else{
$data[$i+1]=($data[$i]*$rest[$i]); }
}
$c=$b*$data[$P-1-$x]%$P; $plain=$c;
return $c; }
function
ELGAMALENC($plainText,$mynumber,$yournumber,$P,$G){ for($i=0;$i<strlen($plainText);$i++){
$c='';
$a=bin2hex($plainText[$i]); $b=hexdec($a);
if($b<=$P){
$c=oneenc($b,$mynumber,$yournumber,$P,$G); if(strlen(dechex($c))==1)
{
$enc1='0'.dechex($c); }
else{
$enc1=dechex($c); }
$enc=$enc.hex2bin($enc1); }
else{
$enc1=dechex($b);
$enc=$enc.hex2bin($enc1); }
}
//return $CHIPERTEXT; return $enc;
function
ELGAMALDEC($chiperText,$mynumber,$yournumber,$P,$G){ for($i=0;$i<strlen($chiperText);$i++){
$c='';
$a1=bin2hex($chiperText[$i]); $a2=hexdec($a1);
if($a2<=$P){
$c=onedec($a2,$mynumber,$yournumber,$P,$G); if(strlen(dechex($c))==1)
{
$dec1='0'.dechex($c); }
else{
$dec1=dechex($c); }
$dec=$dec.hex2bin($dec1); }
else{
$dec1=dechex($a2);
$dec=$dec.hex2bin($dec1); }
}
//return $CHIPERTEXT; return $dec;
} /*
* ALGORITHMA ELGAMAL SELESAI */
Enkripsi
Dekripsi