Senin, 28 Juni 2021

Java Code Read And Write Excell File

 Pasang Library dahulu yaa....



package xlsproject;



import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import org.apache.poi.ss.usermodel.*;


import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.Iterator;

import java.util.logging.Level;

import java.util.logging.Logger;

import org.apache.poi.EncryptedDocumentException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;



public class gabRW {

    String[][]AR;

    

    public static void main(String[] args) throws IOException, InvalidFormatException {

        

        gabRW x=new gabRW();

        x.baca();

        x.tulis();

    }

    

    

    void baca(){

        try {

            String myPath=System.getProperty("user.dir")+"/excell/NORM.xls";

            Workbook workbook = WorkbookFactory.create(new File(myPath));

            int jumsheet=workbook.getNumberOfSheets();

            

            Sheet sheet = workbook.getSheetAt(0);

            DataFormatter dataFormatter = new DataFormatter();


//int noOfColumns = sheet.getRow(0).getPhysicalNumberOfCells();

int kol = sheet.getRow(0).getLastCellNum();

int bar = sheet.getLastRowNum() +1;

AR=new String[bar][kol];


System.out.println("\n\nIterating over Rows and Columns using Iterator\n");

Iterator<Row> rowIterator = sheet.rowIterator();

int r=0;

while (rowIterator.hasNext()) {

    Row row = rowIterator.next();

    Iterator<Cell> cellIterator = row.cellIterator();

    int c=0;

    while (cellIterator.hasNext()) {

        Cell cell = cellIterator.next();

        String cellValue = dataFormatter.formatCellValue(cell);

        System.out.print(cellValue + "\t");

        AR[r][c]=cellValue;

        c++;

    }

    System.out.println();

    r++;

}


workbook.close();

        } catch (IOException ex) {

            Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

        } catch (InvalidFormatException ex) {

            Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

        } catch (EncryptedDocumentException ex) {

            Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

        }

    }


    private static void printCellValue(Cell cell) {

        switch (cell.getCellTypeEnum()) {

            case BOOLEAN:

                System.out.print(cell.getBooleanCellValue());

                break;

            case STRING:

                System.out.print(cell.getRichStringCellValue().getString());

                break;

            case NUMERIC:

                if (DateUtil.isCellDateFormatted(cell)) {

                    System.out.print(cell.getDateCellValue());

                } else {

                    System.out.print(cell.getNumericCellValue());

                }

                break;

            case FORMULA:

                System.out.print(cell.getCellFormula());

                break;

            case BLANK:

                System.out.print("");

                break;

            default:

                System.out.print("");

        }

        System.out.print("\t");

    }

    

    

    

    void tulis(){

        int c=AR[0].length;

        int r=AR.length;

        System.out.println(r+","+c);

        

        FileOutputStream fileOut = null;

        try {

            

            

            Workbook workbook = new XSSFWorkbook();

             CreationHelper createHelper = workbook.getCreationHelper();

             CellStyle POLA = workbook.createCellStyle();

             //dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("dd-MM-yyyy"));

            POLA.setDataFormat(createHelper.createDataFormat().getFormat("#.###############"));

            

            Sheet sheet = workbook.createSheet("datalatih"); 

            int rowNum = 0;

          for(int i=0;i<r;i++){  

                Row row = sheet.createRow(rowNum++);

                for(int j=0;j<c;j++){  

                    String dataXLS=AR[i][j];

                    //System.out.println("data:"+i+","+j+"="+dataXLS);

                    if(i==0){

                    row.createCell(j).setCellValue(dataXLS);

                    }

                    else{

                    Cell myPos = row.createCell(j);

                    myPos.setCellValue(dataXLS);

                    myPos.setCellStyle(POLA);

                    }

                }

          }

            for(int i = 0; i < c; i++) {

                sheet.autoSizeColumn(i);

            }   

            

            

            String myPath=System.getProperty("user.dir")+"/excell/TESTTULIS.xls";

            fileOut = new FileOutputStream(myPath);

            try {

                workbook.write(fileOut);

            } catch (IOException ex) {

                Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

            }

            try {

                fileOut.close();

            } catch (IOException ex) {

                Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

            }

            try {

                workbook.close();

            } catch (IOException ex) {

                Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

            }

        } catch (FileNotFoundException ex) {

            Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

        } finally {

            try {

                fileOut.close();

            } catch (IOException ex) {

                Logger.getLogger(gabRW.class.getName()).log(Level.SEVERE, null, ex);

            }

        }

    }

}


Cukup satu file saja...




Download Latihan

Kamis, 25 Juni 2020

Java Code Selisih Waktu Absensi




  String gstatus_masuk="";
    String jterlambat="";
    String gstatus_pulang="";
    String jlebih_awal="";
    String jlembur="";








void MASUK(String nik){
   
  Calendar cal = Calendar.getInstance();       
  int tgl= cal.get(Calendar.DATE);
  int bln= cal.get(Calendar.MONTH)+1;
  int thn= cal.get(Calendar.YEAR);
 
  int hh= cal.get(Calendar.HOUR);
  int mm= cal.get(Calendar.MINUTE);
  int ss= cal.get(Calendar.SECOND);
 
  String tanggal_masuk=thn+"-"+bln+"-"+tgl;
  String jam_masuk=hh+":"+mm+":"+ss;
  //===========================================
        String Jharus="08:00:00";
        String Tharus=tanggal_masuk;
       
        String Jdatang=jam_masuk;
        String Tdatang=tanggal_masuk;
       
        String Wmasuk=Tharus+" "+Jharus;
        String Wpulang=Tdatang+" "+Jdatang;
     
        long cekmasuk=  getMenit(Wmasuk,Wpulang);
        if(cekmasuk>0){
          gstatus_masuk="Terlambat";
          jterlambat=String.valueOf(cekmasuk);
      }
      else{
          gstatus_masuk="OnTime";
          jterlambat=String.valueOf("0");     
      }
      System.out.println(gstatus_masuk+"#"+jterlambat);

try{query="INSERT INTO `tb_absensi`(`id_absensi`, `nik`, `tanggal_masuk`, `status_masuk`, `jam_masuk`, `terlambat`, `tanggal_pulang`,`jam_pulang`,`status_pulang`,`lebih_awal`,`durasi_lembur`, `status`, `keterangan`) VALUES ('0','"+nik+"','"+tanggal_masuk+"','"+gstatus_masuk+"','"+jam_masuk+"','"+jterlambat+"','','','','0','0','Masuk','')";
System.out.println(query);         
kon.QUERY2(query,"Simpan");
 
            }catch(Exception sqle){
        }
}



void PULANG(String IDABSENSI,String IDF){
   
  Calendar cal = Calendar.getInstance();       
  int tgl= cal.get(Calendar.DATE);
  int bln= cal.get(Calendar.MONTH)+1;
  int thn= cal.get(Calendar.YEAR);
 
  int hh= cal.get(Calendar.HOUR);
  int mm= cal.get(Calendar.MINUTE);
  int ss= cal.get(Calendar.SECOND);
 
  String tanggal_pulang=thn+"-"+bln+"-"+tgl;
  String jam_pulang=hh+":"+mm+":"+ss;
  //===========================================
       String Jharus="17:00:00";
        String Tharus=tanggal_pulang;
       
        String Jdatang=jam_pulang;
        String Tdatang=tanggal_pulang;
       
        String Wmasuk=Tharus+" "+Jharus;
        String Wpulang=Tdatang+" "+Jdatang;
      long cekpulang=  getMenit(Wmasuk,Wpulang);
      if(cekpulang<0){
          gstatus_pulang="Pulang Awal";
          jlebih_awal=String.valueOf(cekpulang);
          jlembur=String.valueOf("0");
      }
      else{
         gstatus_pulang="Ontime";
          jlebih_awal=String.valueOf("0");
          jlembur=String.valueOf(cekpulang);
      }
     
try{
    String keterangan="Scan IDF "+IDF;
    query="UPDATE `tb_absensi` SET`tanggal_pulang`='"+tanggal_pulang+"',`jam_pulang`='"+jam_pulang+"',`status_pulang`='"+gstatus_pulang+"',`lebih_awal`='"+jlebih_awal+"',`durasi_lembur`='"+jlembur+"',`status`='Pulang',`keterangan`='"+keterangan+"' WHERE `id_absensi`='"+IDABSENSI+"'";
    System.out.println(query);       

    kon.QUERY2(query,"Ubah");

}catch(Exception sqle){
        }
}





      void cekMasuk(){
        String Jharus="08:00:00";
        String Tharus="2020-02-06";
       
        String Jdatang="07:00:00";
        String Tdatang="2020-02-06";
       
        String Wmasuk=Tharus+" "+Jharus;
        String Wpulang=Tdatang+" "+Jdatang;
      long cekmasuk=  getMenit(Wmasuk,Wpulang);
      if(cekmasuk>0){
          gstatus_masuk="Terlambat";
          jterlambat=String.valueOf(cekmasuk);
      }
      else{
          gstatus_masuk="OnTime";
          jterlambat=String.valueOf("0");     
      }
      System.out.println(gstatus_masuk+"#"+jterlambat);
     
    }
     
     
     
       void cekPulang(){
        String Jharus="15:00:00";
        String Tharus="2020-02-06";
       
        String Jdatang="16:00:00";
        String Tdatang="2020-02-06";
       
        String Wmasuk=Tharus+" "+Jharus;
        String Wpulang=Tdatang+" "+Jdatang;
      long cekpulang=  getMenit(Wmasuk,Wpulang);
      if(cekpulang<0){
          gstatus_pulang="Pulang Awal";
          jlebih_awal=String.valueOf(cekpulang);
          jlembur=String.valueOf("0");
      }
      else{
         gstatus_pulang="Ontime";
          jlebih_awal=String.valueOf("0");
          jlembur=String.valueOf(cekpulang);
      }
      System.out.println(gstatus_pulang+"#jlembur="+jlembur+"#jlebih_awal="+jlebih_awal);
     
    }
     
       
long getMenit(String dateStart,String dateStop){   
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = null;
Date d2 = null;
long menit=0;
try {
  d1 = format.parse(dateStart);
  d2 = format.parse(dateStop);

  long diff = d2.getTime() - d1.getTime();
  long diffSeconds = diff / 1000 % 60;
  long diffMinutes = diff / (60 * 1000) % 60;
  long diffHours = diff / (60 * 60 * 1000) % 24;
  long diffDays = diff / (24 * 60 * 60 * 1000);

  menit=(diffDays*24*60)+(diffHours*60)+diffMinutes;
 
//  System.out.print(diffDays + " days, ");
//  System.out.print(diffHours + " hours, ");
//  System.out.print(diffMinutes + " minutes, ");
//  System.out.print(diffSeconds + " seconds.");
   System.out.print(menit + " menit.");

} catch (Exception e) {
   e.printStackTrace();
}
return menit;
    }











void FingerPrint(String comm){
          try {
              rxtx= new Win10RxTx();;
              rxtx.connect(comm);
              lanjut();
          } catch (Exception ex) {
              Logger.getLogger(MenuUtamaAdmin.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
void lanjut(){
Thread readData = new Thread(new Runnable() {
@Override
public void run() {
String data;
while(true) {
if (Thread.interrupted()) break;
data = rxtx.read();
if (data != null) {
                                                    if(data.indexOf("Found ID #")>=0){
                                                        String ar[]=data.split("Found ID #");
                                                        String data1[]=ar[1].split(" ");
                                                       
                                                        String IDF=data1[0];
                                                        System.out.println("#IDF="+IDF+"#");
                                                        cekStatus(IDF);
                                                   
                                                    }
System.out.println("!"+data+"#");
//System.out.println((new SimpleDateFormat(" {HH:mm:ss}")).format(new Date()));
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
}
}
});
readData.start();


}


int cekStatus(String IDF){
   
    Calendar cal = Calendar.getInstance();       
  int tgl= cal.get(Calendar.DATE);
  int bln= cal.get(Calendar.MONTH)+1;
  int thn= cal.get(Calendar.YEAR);
 
  int hh= cal.get(Calendar.HOUR);
  int mm= cal.get(Calendar.MINUTE);
  int ss= cal.get(Calendar.SECOND);
 
  String stgl=thn+"-"+bln+"-"+tgl;
 
 
    String NIK="";
    String query = "Select `nik` From `tb_karyawan` where `keterangan` ='"+IDF+"'";
        ResultSet rs;
        try {
            rs = st.executeQuery(query);
            if(rs.next()) {
                NIK = rs.getString("nik");
            }
        } catch (SQLException ex) {}
       
   
        String statusAbsen="Pulang";   
        String IDABSENSI="";   
       
        query = "Select `status`,`id_absensi` From `tb_absensi` where `nik` ='"+NIK+"' and `tanggal_masuk`='"+stgl+"' order by `id_absensi` desc";
        System.out.println(query);
        try {
            rs = st.executeQuery(query);
            if(rs.next()) {
               statusAbsen = rs.getString("status");
               IDABSENSI= rs.getString("id_absensi");
               System.out.println("IDABSENSI="+IDABSENSI);
            }
        } catch (SQLException ex) {}
       
        if(statusAbsen.equalsIgnoreCase("Masuk")){
        //update
            PULANG(IDABSENSI,IDF);
        }
        else if(statusAbsen.equalsIgnoreCase("Pulang")){//jk terahir status=Pulang
        //insert
        MASUK(NIK);
        }
        else{
            if(NIK.length()>3){
                 System.out.println("ABSEN MASUK "+IDF);
            }
            else{
            System.out.println("No Detect "+IDF);
            }
        }

        return 0;
}

JAVA THREAD SERIAL

Membuat komunikasi Serial pada java dengan Tanpa LOCK

package rxtx;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Win10RxTxTest {

      Win10RxTx rxtx ;
    void baca(){
     Thread thread = new Thread(){
        public void run(){ 
            System.out.println("Thread Running");
        }
        };
  thread.start();
    }
        void baca2(){
     Thread thread = new Thread(){
        public void run(){ 
            System.out.println("Thread Running22");
        }
        };
  thread.start();
    }
public static void main ( String[] args ) {
         
            Win10RxTxTest x=new Win10RxTxTest();     
                x.baca();
  System.out.println("OKAAA");
   
           
                x.sambung();
                    x.lanjut();
                System.out.println("OK");

                 x.baca2();
        }
       
       
        void sambung(){
          try {
              rxtx= new Win10RxTx();;
              rxtx.connect("COM13");
          } catch (Exception ex) {
              Logger.getLogger(Win10RxTxTest.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        void lanjut(){
Thread readData = new Thread(new Runnable() {
@Override
public void run() {
String data;
while(true) {
if (Thread.interrupted()) break;
data = rxtx.read();
if (data != null) {
System.out.print(data);

//the real-time when data arrived
System.out.println(
(new SimpleDateFormat(" {HH:mm:ss}"))
.format(new Date()));
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
}
}
});
readData.start();


}
       
       
       
       
        void sambungLock(){
          try {
              rxtx= new Win10RxTx();;
              rxtx.connect("COM13");
          } catch (Exception ex) {
              Logger.getLogger(Win10RxTxTest.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
        void lanjut2(){
Thread readData = new Thread(new Runnable() {
@Override
public void run() {
String data;
while(true) {
if (Thread.interrupted()) break;
data = rxtx.read();
if (data != null) {
System.out.print(data);

//the real-time when data arrived
System.out.println(
(new SimpleDateFormat(" {HH:mm:ss}"))
.format(new Date()));
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
}
}
});
readData.start();

//Define a input thread to get input from the user and send to RxTx
Thread userInput = new Thread(new Runnable() {
@Override
public void run() {
int c = 0;
byte[] buf = new byte[1204];
try {
while ( ( c = System.in.read(buf)) > -1 )
{
if (Thread.interrupted()) break;
//"---" is a string to terminate the program
if (c > 0) {
if (c==5 && buf[0]=='-'
&& buf[1]=='-' && buf[2]=='-') {
break;
}
//"+++" is a special string sent to RxTx
if (c==5 && buf[0]=='+'
&& buf[1]=='+' && buf[2]=='+') {
c = 3;
}
rxtx.write(Arrays.copyOf(buf, c));
}                            
}
} catch (IOException e) {
e.printStackTrace();
}               
}
});
userInput.start();

//Normally the program is terminated by the user
//so we wait for the input thread to finish
userInput.join();
readData.interrupt();
readData.join();


}
}




Minggu, 22 Maret 2020

Apliaksi Java Kriptografi Kombinasi

run:
NF=tes3.txt
pathnya=E:\___CORONA\_Java\AUdio_Steganos\KriptografiModTwofish\
fileName=E:\___CORONA\_Java\AUdio_Steganos\KriptografiModTwofish\tes3.txt
EXT=txt
enNF=E:\___CORONA\_Java\AUdio_Steganos\KriptografiModTwofish\en_tes3.txt
dekNF=E:\___CORONA\_Java\AUdio_Steganos\KriptografiModTwofish\dec_tes3.txt

++++++++++++PESAN++++++++++++++++
HALO APA KABAR LP2MARAY JAKARTA 082111476069 OK SELALU !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
H.40=A.33=JML=73%128=73=>105=i
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=b.66=JML=99%128=5=>37=%
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
L.44=c.67=JML=111%128=17=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
O.47=d.68=JML=115%128=21=>53=5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=e.69=JML=69%128=69=>101=e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=f.70=JML=103%128=9=>41=)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
P.48=1.17=JML=65%128=65=>97=a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=2.18=JML=51%128=51=>83=S
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=A.33=JML=33%128=33=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
K.43=b.66=JML=109%128=15=>47=/
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=c.67=JML=100%128=6=>38=&
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
B.34=d.68=JML=102%128=8=>40=(
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=e.69=JML=102%128=8=>40=(
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
R.50=f.70=JML=120%128=26=>58=:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=1.17=JML=17%128=17=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
L.44=2.18=JML=62%128=62=>94=^
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
P.48=A.33=JML=81%128=81=>113=q
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
2.18=b.66=JML=84%128=84=>116=t
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
M.45=c.67=JML=112%128=18=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=d.68=JML=101%128=7=>39='
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
R.50=e.69=JML=119%128=25=>57=9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=f.70=JML=103%128=9=>41=)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
Y.57=1.17=JML=74%128=74=>106=j
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=2.18=JML=18%128=18=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
J.42=A.33=JML=75%128=75=>107=k
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=b.66=JML=99%128=5=>37=%
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
K.43=c.67=JML=110%128=16=>48=0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=d.68=JML=101%128=7=>39='
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
R.50=e.69=JML=119%128=25=>57=9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
T.52=f.70=JML=122%128=28=>60=<
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=1.17=JML=50%128=50=>82=R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=2.18=JML=18%128=18=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
0.16=A.33=JML=49%128=49=>81=Q
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
8.24=b.66=JML=90%128=90=>122=z
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
2.18=c.67=JML=85%128=85=>117=u
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
1.17=d.68=JML=85%128=85=>117=u
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
1.17=e.69=JML=86%128=86=>118=v
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
1.17=f.70=JML=87%128=87=>119=w
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
4.20=1.17=JML=37%128=37=>69=E
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
7.23=2.18=JML=41%128=41=>73=I
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
6.22=A.33=JML=55%128=55=>87=W
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
0.16=b.66=JML=82%128=82=>114=r
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
6.22=c.67=JML=89%128=89=>121=y
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
9.25=d.68=JML=93%128=93=>125=}
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=e.69=JML=69%128=69=>101=e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
O.47=f.70=JML=117%128=23=>55=7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
K.43=1.17=JML=60%128=60=>92=\
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=2.18=JML=18%128=18=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
S.51=A.33=JML=84%128=84=>116=t
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
E.37=b.66=JML=103%128=9=>41=)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
L.44=c.67=JML=111%128=17=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
A.33=d.68=JML=101%128=7=>39='
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
L.44=e.69=JML=113%128=19=>51=3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
U.53=f.70=JML=123%128=29=>61==
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
 .0=1.17=JML=17%128=17=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES ENKRIP MOD++++++++++++++++
!.1=2.18=JML=19%128=19=>51=3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++MOD++++++++++++++++
i%15e)aSA/&((:1^qt2'9)j2k%0'9<R2QzuuvwEIWry}e7\2t)1'3=13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++MOD+TW++++++++++++++++
7ᆱ$)￀H£ヒミ U↑($ᅴ ○dᄅル￉ユ{ᅴ￲e￞￈{￀,SᅵニdL)Tᆱ￰;ᄏ;~Rノフᅩᆵ,￴PRᅮW ¦ ᅠYke￵2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++DEKRIP+TW1++++++++++++++++
7ᆱ$)￀H£ヒミ U↑($ᅴ ○dᄅル￉ユ{ᅴ￲e￞￈{￀,SᅵニdL)Tᆱ￰;ᄏ;~Rノフᅩᆵ,￴PRᅮW ¦ ᅠYke￵2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++DEKRIP+TW1++++++++++++++++
i%15e)aSA/&((:1^qt2'9)j2k%0'9<R2QzuuvwEIWry}e7\2t)1'3=13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
i.73=A.33=JML=40+32=>72=H
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
%.5=b.66=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
1.17=c.67=JML=44+32=>76=L
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
5.21=d.68=JML=47+32=>79=O
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
e.69=e.69=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
).9=f.70=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
a.65=1.17=JML=48+32=>80=P
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
S.51=2.18=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
A.33=A.33=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
/.15=b.66=JML=43+32=>75=K
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
&.6=c.67=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
(.8=d.68=JML=34+32=>66=B
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
(.8=e.69=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
:.26=f.70=JML=50+32=>82=R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
1.17=1.17=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
^.62=2.18=JML=44+32=>76=L
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
q.81=A.33=JML=48+32=>80=P
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
t.84=b.66=JML=18+32=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
2.18=c.67=JML=45+32=>77=M
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
'.7=d.68=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
9.25=e.69=JML=50+32=>82=R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
).9=f.70=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
j.74=1.17=JML=57+32=>89=Y
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
2.18=2.18=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
k.75=A.33=JML=42+32=>74=J
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
%.5=b.66=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
0.16=c.67=JML=43+32=>75=K
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
'.7=d.68=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
9.25=e.69=JML=50+32=>82=R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
<.28=f.70=JML=52+32=>84=T
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
R.50=1.17=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
2.18=2.18=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
Q.49=A.33=JML=16+32=>48=0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
z.90=b.66=JML=24+32=>56=8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
u.85=c.67=JML=18+32=>50=2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
u.85=d.68=JML=17+32=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
v.86=e.69=JML=17+32=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
w.87=f.70=JML=17+32=>49=1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
E.37=1.17=JML=20+32=>52=4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
I.41=2.18=JML=23+32=>55=7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
W.55=A.33=JML=22+32=>54=6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
r.82=b.66=JML=16+32=>48=0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
y.89=c.67=JML=22+32=>54=6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
}.93=d.68=JML=25+32=>57=9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
e.69=e.69=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
7.23=f.70=JML=47+32=>79=O
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
\.60=1.17=JML=43+32=>75=K
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
2.18=2.18=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
t.84=A.33=JML=51+32=>83=S
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
).9=b.66=JML=37+32=>69=E
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
1.17=c.67=JML=44+32=>76=L
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
'.7=d.68=JML=33+32=>65=A
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
3.19=e.69=JML=44+32=>76=L
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
=.29=f.70=JML=53+32=>85=U
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
1.17=1.17=JML=94+32=>32=
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++PROSES DEKRIP MOD++++++++++++++++
3.19=2.18=JML=1+32=>33=!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++++++++++++DEKRIP+MOD++++++++++++++++
HALO APA KABAR LP2MARAY JAKARTA 082111476069 OK SELALU !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
BUILD SUCCESSFUL (total time: 0 seconds)

Ini COdenya yaa...
package audiost2;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BBtesMod_dan_Twofish {
    static String[]arx;
    static int lop;
     public static int jbit=-1;//44;
    public static int mod=255;//ini adalah moddulus valuenya ...bebas antara 128 sd 255 ambang batas max ascii
    public static int opr=100;//65 ini adalah pergeseran Valuenya=bebas antara 0 sd 255


  String getBaca(String fileName) throws IOException{
     String everything="";
BufferedReader br = new BufferedReader(new FileReader(fileName));
try {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();

    while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
    }
     everything = sb.toString();
} finally {
    br.close();
}
return everything;
}  
    
String getDefault(String fileName) throws IOException{
String gab="";
Path path = Paths.get(fileName);
        byte[] data = Files.readAllBytes(path); //membaca semua bytes yang ada di object
        for(int i=0; i < data.length; i++) {
            String al = String.valueOf(data[i] & 0xff); 
             int ii=Integer.parseInt(al);
             char c=(char)ii;
             gab=gab+c;
         }   
 return gab;
}



String getDefault2(String fileName) throws IOException{
String gab="";
        BufferedReader be = null;
            String current;
            be = new BufferedReader(new FileReader(fileName));
            while ((current = be.readLine()) != null) {
                gab +=  current;
            }
 return gab;
}

static String getNF(String fileName){
    int dot = fileName.lastIndexOf(".");
    int sep = fileName.replace("\\", "/").lastIndexOf("/");
    String NF=fileName.substring(sep + 1, dot);
    String extendeed= fileName.substring(dot + 1);
    NF=NF+"."+extendeed;
return NF;
}
static String getExt(String fileName){
    int dot = fileName.lastIndexOf(".");
    String extendeed= fileName.substring(dot + 1);
return extendeed;
}

public static void main(String[] args) throws IOException {
      String alamat=System.getProperty("user.dir");
      String fileName=alamat+"\\tes3.txt";
      
      
    BBtesMod_dan_Twofish mybb=new BBtesMod_dan_Twofish();
    
String NF=BBtesMod_dan_Twofish.getNF(fileName); 
String EXT=BBtesMod_dan_Twofish.getExt(fileName);
String pathnya=fileName.replaceAll(NF, "");
String enNF=pathnya+"en_"+NF; 
String dekNF=pathnya+"dec_"+NF;
 
System.out.println("NF="+NF);
System.out.println("pathnya="+pathnya);
System.out.println("fileName="+fileName);
System.out.println("EXT="+EXT);
System.out.println("enNF="+enNF);
System.out.println("dekNF="+dekNF);

String PASS = "Abcdef12";
String MSG=mybb.getDefault2(fileName);
mybb.cetak("PESAN",MSG);


//==============================================
String chipper10=mybb.encrypt26(MSG,PASS);
mybb.cetak("MOD",chipper10);

String chipper20=mybb.enkripTW(chipper10,PASS);
mybb.cetak("MOD+TW",chipper20);

saveString(chipper20,enNF);



//===================   

String MSG2=chipper20;//mybb.getDefault2(enNF);

mybb.cetak("Dekrip+TW1",chipper20);

String dekrip10=mybb.dekripTW(MSG2,PASS);//decode
mybb.cetak("Dekrip+TW1",dekrip10);

String hasil=mybb.decrypt26(dekrip10,PASS);
mybb.cetak("Dekrip+MOD",hasil);
    
saveString(hasil,dekNF);
//hasil="Sukses Dekrip";
//mybb.cetak("DEKRIP",hasil);
     




}//main


private static String encrypt26(String plainText, String PASS) {
    
BBtesMod_dan_Twofish mybb=new BBtesMod_dan_Twofish();
String secretKey="";
int x=plainText.length();
int y=PASS.length();
int p=(x/y)+1;
for(int i=0;i<p;i++){
    secretKey+=PASS;
}
StringBuffer encryptedString = new StringBuffer();
int encryptedInt;
  for (int i = 0; i < plainText.length(); i++) {
      char H1=plainText.charAt(i);
      char H2=secretKey.charAt(i);
      
int plainTextInt = (int) (plainText.charAt(i) - ' ');
int secretKeyInt = (int) (secretKey.charAt(i) - ' ');
int JML=(plainTextInt + secretKeyInt);
                        
                        encryptedInt = JML % 94;//128
                        int JD=(encryptedInt) + (int) (' ');
                        char HRP=(char)JD;
                        mybb.cetak("PROSES ENKRIP MOD",H1+"."+plainTextInt+"="+H2+"."+secretKeyInt+"=JML="+JML+"%128="+encryptedInt+"=>"+JD+"="+HRP);
                        
encryptedString.append(HRP);
}
return encryptedString.toString();
}

private static String decrypt26(String decryptedText, String PASS) {
    BBtesMod_dan_Twofish mybb=new BBtesMod_dan_Twofish();
String secretKey="";
int x=decryptedText.length();
int y=PASS.length();
int p=(x/y)+1;
for(int i=0;i<p;i++){
    secretKey+=PASS;
}
StringBuffer decryptedString = new StringBuffer();
int decryptedInt;
for (int i = 0; i < decryptedText.length(); i++) {
       char H1=decryptedText.charAt(i);
        char H2=secretKey.charAt(i);
      
int decryptedTextInt = (int) (decryptedText.charAt(i) - ' ');
int secretKeyInt = (int) (secretKey.charAt(i) - ' ');
decryptedInt = decryptedTextInt - secretKeyInt;
if (decryptedInt < 1)
decryptedInt += 94;//128
                        
                        
                        int JML=decryptedInt;
                        int JD=(decryptedInt) + (int) (' ');
                        if(JD>=126){JD=32;}
                        
                        char HRP=(char)JD;
                          
decryptedString.append(HRP);
                        
                        
                       
                        
                        
                        
                        mybb.cetak("PROSES DEKRIP MOD",H1+"."+decryptedTextInt+"="+H2+"."+secretKeyInt+"=JML="+JML+"+32=>"+JD+"="+HRP);
                   
                             
}
return decryptedString.toString();
        
void  cetak(String kat,String pesan){
System.out.println("++++++++++++"+kat.toUpperCase()+"++++++++++++++++");
System.out.println(pesan);
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

}
String enkripTW(String plainText, String PASS){
 String strTW=myEnkrip(plainText,PASS);
return strTW;
}


String dekripTW(String plainText, String PASS){
 String strDekrip=myDekrip(plainText,PASS);
return strDekrip;
}


String enkripMod(String plainText, String PASS){
String gabKey="";
int x=plainText.length();
int y=PASS.length();
int p=(x/y)+1;
for(int i=0;i<p;i++){
    gabKey+=PASS;
}

String chipper=encryptM(plainText, gabKey);

return chipper;
}

String dekripMod(String chipper, String PASS){
String gabKey="";
int x=chipper.length();
int y=PASS.length();
int p=(x/y)+1;
for(int i=0;i<p;i++){
    gabKey+=PASS;
}

String decryptedText = decryptM(chipper, gabKey);
//System.out.println("DEKRIP="+decryptedText);
return decryptedText;
}


static String myEnkrip(String PTEXT,String PASS){ 
        int p=PTEXT.length();
        int split=16;
        if(p>split){
        int sisa=p%16;
        lop=p/16;
        if(sisa>0){lop=lop+1;}
        arx=new String[lop];
        int awal=0;
            for(int l=0;l<lop-1;l++){
                int next=(awal+split);
                    arx[l]=PTEXT.substring(awal,next);
                    // System.out.println(l+"="+arx[l]+"=="+awal+","+(next));
                    awal+=split;
                 }
                 if(sisa>0){
                 arx[lop-1]=PTEXT.substring(awal,awal+sisa);
                 }
            }//>16

            String gabEnkrip="";
            for(int i=0;i<lop;i++){
                    String cip="";
                    try{cip=BBtesMod_dan_Twofish.enkrip(arx[i], PASS);}
                    catch(Exception ee){}
                    gabEnkrip+=cip;
            }
return gabEnkrip;
}

static String myDekrip(String gabEnkrip,String PASS){ 
      String gabDek="";
      int split=16;
       int pdek=gabEnkrip.length();
       int lopdek=pdek/split;
       int awaldek=0;
       String[]ard=new String[lopdek];
        for(int l=0;l<lopdek-0;l++){
            int next=awaldek+split;
            ard[l]=gabEnkrip.substring(awaldek,next);
            String dek=BBtesMod_dan_Twofish.dekrip(ard[l], PASS);
           //  System.out.println(l+"="+ard[l]+"=="+awaldek+","+next+"=="+dek);
            gabDek+=dek.trim();
            awaldek+=split;
        }
return gabDek;      
}



static  String enkrip(String PTEXT,String PASS){                        
byte tempKey[] = PASS.getBytes();
byte tempPlainText[] = null;
        try{
       tempPlainText= PTEXT.getBytes();
        }
        catch(Exception ee){  
        }
        byte key[] = new byte[32];
byte plainText[] = new byte[128];
int i;
            for(i=0; i<32;i++){
                if(i<tempKey.length)  key[i] = tempKey[i];
else key[i] = (byte)0;
            }
            for(i=0; i<128;i++){
                if(i<tempPlainText.length) { 
                try{
                    plainText[i] = tempPlainText[i];
                }
                catch(Exception ee){}
                }
else plainText[i] = (byte)0;
            }
Object K = null;
        try {
            K = Twofish_Algorithm.makeKey(key);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(BBtesMod_dan_Twofish.class.getName()).log(Level.SEVERE, null, ex);
        }
byte[] ct = Twofish_Algorithm.blockEncrypt(plainText, 0, K);
               
        String cipherText="";
        for( i=0;i<ct.length;i++){
            cipherText+=String.valueOf((char)ct[i]);
        }
    return cipherText;                    
    }

static String dekrip(String cipherText,String PASS){   
    byte tempKey2[] = PASS.getBytes();
    byte key2[] = new byte[32];
for(int i=0; i<32;i++){
            if(i<tempKey2.length)  key2[i] = tempKey2[i];
            else key2[i] = (byte)0;
        }
         
            char[]arh=cipherText.toCharArray();
            byte[]cth=new byte[arh.length];
            for(int  i=0;i<arh.length;i++){
                  cth[i]=(byte)(int)arh[i];
            }  
                
        Object K2 = null;
        try {
            K2 = Twofish_Algorithm.makeKey(key2);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(BBtesMod_dan_Twofish.class.getName()).log(Level.SEVERE, null, ex);
        }
byte[] cpt = Twofish_Algorithm.blockDecrypt(cth, 0, K2);//ct
String ot = new String(cpt);
return ot;
    }
    
      private void saveByte(byte[] dataDecrypt,String fileNameEncrypt) throws IOException {
       Path path = Paths.get(fileNameEncrypt);
       Files.write(path, dataDecrypt); //creates, overwrites
       //System.out.println("File Berhasil di dekripsi ! lihat di : " +fileNameEncrypt);
     }    
      
       static void saveString(String dataEncrypt,String namaFile) {
          try {
           String content = dataEncrypt;
           File file = new File(namaFile);
           if (!file.exists()) {
               file.createNewFile();
           }
           
           FileWriter fw = new FileWriter(file.getAbsoluteFile());
           BufferedWriter bw = new BufferedWriter(fw);
           bw.write(content);
           bw.close();
       }    catch (IOException e) {
           e.printStackTrace();
       }
   }
       
       
       
       
       private static String encryptM(String plainText, String secretKey) {
StringBuffer encryptedString = new StringBuffer();
int encryptedInt;
for (int i = 0; i < plainText.length(); i++) {
                        int ch1=(plainText.charAt(i) - opr);
                        int ch2=(secretKey.charAt(i) - opr);
                        int hsl=ch1 + ch2+ opr;
                        int hsl0=hsl;
                        if (hsl < 1){
hsl += mod;
                        }
                                
                        encryptedInt = (hsl) % mod;
                        char hasil=(char)encryptedInt;
                      //  String str="E"+i+"."+ch1+"+"+ch2+"+"+opr+"="+hsl0+"=mod ="+encryptedInt+"="+String.valueOf(hasil);
                       // cetak(str);
                        encryptedString.append(hasil);
                }
return plainText.toString();
}

     
private static String decryptM(String decryptedText, String secretKey) {
StringBuffer decryptedString = new StringBuffer();
int decryptedInt;
for (int i = 0; i < decryptedText.length(); i++) {
int ch1 = (int) (decryptedText.charAt(i) - opr);
int ch2 = (int) (secretKey.charAt(i) - opr);
int hsl = ch1 - ch2;
                        int hsl0=hsl;
if (hsl < 1){
hsl += mod;
                        }
                        
                        decryptedInt=hsl+ opr;
                        decryptedInt = (decryptedInt) % mod;
                              
                        char hasil=(char)decryptedInt;
                      //  String str="D"+i+"."+ch1+"-"+ch2+"="+hsl0+"=+mod="+decryptedInt+"="+String.valueOf(hasil);
                      //  cetak(str);

//decryptedString.append((char) ((decryptedInt) + (int) 'A'));
                        decryptedString.append(hasil);
}
return decryptedText.toString();
}
        
        
        
//=-===================================
        
        
   private String function(int x){
        Integer res = x*7 + 55;
        return res.toString();
    }

    private int inverse_function(String x){
        int res = (Integer.parseInt(x) - 55)/7;
        return res;
    }

    public void Encode(byte[] data, String textA,String NF2) throws IOException{

     
     String c="000000";
         
String gab0=String.valueOf(c+"&?");
String textbaru0=gab0+String.valueOf(textA);

     byte[] foo0 = textbaru0.getBytes();
     int tl=foo0.length;
     String t2=String.valueOf(tl);
         if(tl<10){
            c="00000"+t2;
         }
         else if(tl<100){
            c="0000"+t2;   
         }
         else if(tl<1000){
            c="000"+t2;
         }
         else if(tl<10000){
            c="00"+t2;
         }
         else if(tl<100000){
            c="0"+t2;
         }
        else{
            c=t2;
         }
    String gab=String.valueOf(c+"&?");//KODE PENGENAL
    String textbaru=gab+String.valueOf(textA);

cetak("AWAL:",textbaru); 
 byte[] foo = textbaru.getBytes();
        for(int i = 0; i < tl; i++){
                data[i] = foo[i];
        }
     
        
        File file2 = new File(NF2);
        FileOutputStream out = new FileOutputStream(file2);
        out = new FileOutputStream(file2);
        out.write(data);
        out.close();
    }

    public String Decode(byte[] data){
        ArrayList<Byte> val1 = new ArrayList<Byte>();
        for(int i = 0; i < 8; i++){
                val1.add(data[i]);
        }
        
        Byte[] ans1 = val1.toArray(new Byte[val1.size()]);
        byte[] res1 = new byte[ans1.length];
        for(int i = 0; i < ans1.length; i++)
            res1[i] = (byte) ans1[i];
        
        
        String result1 = new String(res1);
        String kode=result1.substring(6,8);
        String pjg=result1.substring(0,6);
        int P=Integer.parseInt(pjg)+8;//8 krn ditambah karakter bantu dan jumlah bit
        String result2="";
        cetak("DECODE6BIT",result1);
        
        if(kode.equalsIgnoreCase("&?")){//KODE PENGENAL
        //==================================================
            ArrayList<Byte> val2 = new ArrayList<Byte>();
            for(int i = 0; i < P; i++){//data.length =>P
                    val2.add(data[i]);
            }

            Byte[] ans2 = val2.toArray(new Byte[val2.size()]);
            byte[] res2 = new byte[ans2.length];
            for(int i = 0; i < ans2.length; i++)
                res2[i] = (byte) ans2[i];


            result2 = new String(res2);
            result2=result2.substring(8,result2.length());
    }
        return result2;
    }
}

Minggu, 05 Januari 2020

Java Code Twofish terhadap File

package twofish;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.InvalidKeyException;
import java.util.logging.Level;
import java.util.logging.Logger;
import twofish.Twofish_Algorithm;

public class TWOFISH {
    static String[]arx;
    static int lop;

//String getDoc(String al){
//String h="";
// File file = null;
//        WordExtractor extractor = null;
//        try {
//            file = new File(al);
//            FileInputStream fis = new FileInputStream(file.getAbsolutePath());
//            HWPFDocument document = new HWPFDocument(fis);
//            extractor = new WordExtractor(document);
//            String[] fileData = extractor.getParagraphText();
//            for (int i = 0; i < fileData.length; i++){
//                if (fileData[i] != null)
//                    h+=fileData[i];
//            }
//        }
//        catch (Exception exep){
//            exep.printStackTrace();
//        }
//        return h;
//}

String getDefault(String fileName) throws IOException{
String gab="";
Path path = Paths.get(fileName);
        byte[] data = Files.readAllBytes(path); //membaca semua bytes yang ada di object
        for(int i=0; i < data.length; i++) {
            String al = String.valueOf(data[i] & 0xff);
             int ii=Integer.parseInt(al);
             char c=(char)ii;
             gab=gab+c;
         } 

        BufferedReader be = null;
            String current;
            be = new BufferedReader(new FileReader(fileName));
            while ((current = be.readLine()) != null) {
                gab +=  current;
            }
 return gab;
}

static String getNF(String fileName){
int dot = fileName.lastIndexOf(".");
int sep = fileName.replace("\\", "/").lastIndexOf("/");
String NF=fileName.substring(sep + 1, dot);
String extendeed= fileName.substring(dot + 1);
NF=NF+"."+extendeed;
return NF;
}
static String getExt(String fileName){
int dot = fileName.lastIndexOf(".");
String extendeed= fileName.substring(dot + 1);
return extendeed;
}

public static void main(String[] args) throws IOException {
 TWOFISH x=new TWOFISH();
 String ext=".pdf";
 String fileName="D:\\wav\\contoh"+ext;
 String PASS = "1234567890";

String NF=TWOFISH.getNF(fileName);
String pathnya=fileName.replaceAll(NF, "");

System.out.println("fileName="+fileName);
System.out.println("NF="+NF);
System.out.println("pathnya="+pathnya);

String gab="";
String EXT=TWOFISH.getExt(fileName);
System.out.println("Proses="+EXT);
if(EXT.equalsIgnoreCase("doc")){
     gab=x.getDefault(fileName);//getDoc
}
else if(EXT.equalsIgnoreCase("rtf")){
        gab=x.getDefault(fileName);
}
 else{
     gab=x.getDefault(fileName);
 }

 String enNF=pathnya+"en_"+NF;
 System.out.println("enNF="+enNF);
 String strEnkrip=TWOFISH.myEnkrip(gab,PASS);
 saveString(strEnkrip,enNF);

 String dekNF=pathnya+"dec_"+NF;
 System.out.println("dekNF="+dekNF);
 String strDekrip=TWOFISH.myDekrip(strEnkrip,PASS,dekNF);
 saveString(strDekrip,dekNF);
 
}//main


static String myEnkrip(String PTEXT,String PASS){ 
int p=PTEXT.length();
int split=16;
if(p>split){
int sisa=p%16;
lop=p/16;
if(sisa>0){lop=lop+1;}
arx=new String[lop];
int awal=0;
    for(int l=0;l<lop-1;l++){
        int next=(awal+split);
            arx[l]=PTEXT.substring(awal,next);
            // System.out.println(l+"="+arx[l]+"=="+awal+","+(next));
            awal+=split;
         }
         if(sisa>0){
         arx[lop-1]=PTEXT.substring(awal,awal+sisa);
         }
    }//>16
                           
    String gabEnkrip="";
    for(int i=0;i<lop;i++){
    String cip=TWOFISH.enkrip(arx[i], PASS);
    gabEnkrip+=cip;
    }
return gabEnkrip;
}

static String myDekrip(String gabEnkrip,String PASS,String newfileName){ 
      String gabDek="";
      int split=16;
       int pdek=gabEnkrip.length();
       int lopdek=pdek/split;
       int awaldek=0;
       String[]ard=new String[lopdek];
        for(int l=0;l<lopdek-0;l++){
            int next=awaldek+split;
            ard[l]=gabEnkrip.substring(awaldek,next);
            String dek=TWOFISH.dekrip(ard[l], PASS);
             //System.out.println(l+"="+ard[l]+"=="+awaldek+","+next+"=="+dek);
            gabDek+=dek.trim();
            awaldek+=split;
        }
return gabDek;     
}



static  String enkrip(String PTEXT,String PASS){                       
byte tempKey[] = PASS.getBytes();
byte tempPlainText[] = null;
        try{
       tempPlainText= PTEXT.getBytes();
        }
        catch(Exception ee){}
        byte key[] = new byte[32];
byte plainText[] = new byte[128];

int i;
            for(i=0; i<32;i++){
                if(i<tempKey.length)  key[i] = tempKey[i];
else key[i] = (byte)0;
            }
            for(i=0; i<128;i++){
                if(i<tempPlainText.length) {
                try{
                    plainText[i] = tempPlainText[i];
                }
                catch(Exception ee){}
                }
else plainText[i] = (byte)0;
            }

Object K = null;
        try {
            K = Twofish_Algorithm.makeKey(key);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(TWOFISH.class.getName()).log(Level.SEVERE, null, ex);
        }
byte[] ct = Twofish_Algorithm.blockEncrypt(plainText, 0, K);
             
        String cipherText="";
        for( i=0;i<ct.length;i++){
            cipherText+=String.valueOf((char)ct[i]);
        }
    return cipherText;                   
    }

static String dekrip(String cipherText,String PASS){ 
    byte tempKey2[] = PASS.getBytes();
    byte key2[] = new byte[32];
for(int i=0; i<32;i++){
            if(i<tempKey2.length)  key2[i] = tempKey2[i];
            else key2[i] = (byte)0;
        }
       
            char[]arh=cipherText.toCharArray();
            byte[]cth=new byte[arh.length];
            for(int  i=0;i<arh.length;i++){
                  cth[i]=(byte)(int)arh[i];
            } 
               
        Object K2 = null;
        try {
            K2 = Twofish_Algorithm.makeKey(key2);
        } catch (InvalidKeyException ex) {
            Logger.getLogger(TWOFISH.class.getName()).log(Level.SEVERE, null, ex);
        }
byte[] cpt = Twofish_Algorithm.blockDecrypt(cth, 0, K2);//ct
String ot = new String(cpt);
return ot;
    }
   
      private void saveData(String dataEncrypt,String mpath) {
        String kompress=dataEncrypt;//lz.compress(dataEncrypt, null); 
        char[]ar2=kompress.toCharArray();
            byte[]data3=new byte[ar2.length];
            for(int i=0;i<ar2.length;i++){
                  data3[i]=(byte)(int)ar2[i];
            }             
        try{
            this.saveByte(data3,mpath);   
        } catch (Exception e) {
           e.printStackTrace();
       }

   }
      private void saveByte(byte[] dataDecrypt,String fileNameEncrypt) throws IOException {
       Path path = Paths.get(fileNameEncrypt);
       Files.write(path, dataDecrypt); //creates, overwrites
       System.out.println("File Berhasil di dekripsi ! lihat di : " +fileNameEncrypt);
     }   
     
       static void saveString(String dataEncrypt,String namaFile) {
          try {
           String content = dataEncrypt;
           File file = new File(namaFile);
           if (!file.exists()) {
               file.createNewFile();
           }
         
           FileWriter fw = new FileWriter(file.getAbsoluteFile());
           BufferedWriter bw = new BufferedWriter(fw);
           bw.write(content);
           bw.close();
       }    catch (IOException e) {
           e.printStackTrace();
       }
   }
}