-
help
Enkripsi file
private void jButton1EnActionPerformed(java.awt.event.ActionEve nt evt) {
// TODO add your handling code here:
String temp = "", tampung2;
int temp1 = 0,temp2 = 0,cipherascii = 0;
byte[] m2 = new byte[arr.length];
tampung2 = jTextFieldKunci.getText();
if(tampung2.equals(""))
{ JOptionPane.showMessageDialog(this, "kunci taseh kosong", "information", JOptionPane.INFORMATION_MESSAGE);
}
else
{
for ( int i = 0; i < arr.length; i++ )
{ for ( int k = 0;k < tampung2.length();k++)
{ char b = tampung2.charAt(k);
temp2 = (int) b;
if(k==0)
{
char a = m2.charAt(i);/*error*/
temp1 = (int) a;
cipherascii = temp1 ^ temp2;
}
else
{ temp1 = cipherascii;
cipherascii = temp1 ^ temp2;
}
System.out.println(""+temp1+"xor"+temp2+"="+cipher ascii);
if(k==tampung2.length()-1)
{ String nol = "0000000";
String biner = Integer.toBinaryString(cipherascii);
String binerx;
if(biner.length() < 8)
{ binerx = nol.substring(0, 8-biner.length()) + biner;
}
else binerx = biner;
String cipbiner = binerx.substring(1,8) + binerx.substring(0,1);
int cipascii = Integer.parseInt(cipbiner, 2);
String aChar = new Character((char)cipascii).toString();
temp = temp + aChar ;
System.out.println(cipherascii+"="+binerx+" geser ke kiri 1 byte " + cipbiner);
}
}}}System.out.println(temp);
}
-
Re: help
When posting code, please use the highlight tags to preserve formatting. also, please use a more descriptive title, otherwise most people will simply ignore your post.
You haven't actually posted a problem or a question. What does this code do? What do you expect it to do? Does it compile? Does it throw an Exception? Something else?
Finally, ditch the gui builder until you understand what it's doing under the hood.