Is it possible to write a "decrypter" method for this class?
I came up with the concept for the encryption, but I'm completely puzzled on how to decrypt it..
I came up with the concept for the encryption, but I'm completely puzzled on how to decrypt it..
Code:
//Reid wrote this so don't steal it
import javax.swing.JOptionPane;
public class EncTest {
public static void main(String[] args) {
int[] a = {251,214,120,1,40,190,254,27};
int[] b = {212,232,54,135,244,15,179,80};
String test = JOptionPane.showInputDialog("Input a string.");
String key = JOptionPane.showInputDialog("Input a key.");
int key1 = checksum(key);
int key2 = checksum(b);
enctest(test,key1);
}
public static int checksum(String key){
int z = 0;
int y = 0;
byte[] theKey = key.getBytes();
for(int x = 0;x < key.length(); x++){
z += theKey[x];
}
y = z/256;
y = y*256;
return z-y;
}
public static int checksum(int[] bytes){
int z = 0;
int y = 0;
for(int x = 0;x < bytes.length; x++){
z += bytes[x];
}
y = z/256;
y = y*256;
return z-y;
}
public static void enctest(String enc, int key){
byte[] string = enc.getBytes();
for(int x = 0;x<enc.length();x++){
string[x] = new Integer(((int)string[x]*key)%256).byteValue();
}
String final1 = new String(string);
JOptionPane.showMessageDialog(null,final1);
}
}


