Lets say i got a String of mixed characters, digits/letters/decimalpoints etc. and it´s encrypted.
I have to run them through a for-loop to DEcrypt them, one character at a time.
The first crypt-key is already supplied to ENcrypt the first String "A@F", it´s "113", and i´m supposed
to get the second key by ENcrypting the first String.
There is actually two Strings that are supposed to be handled through for-loops i guess, i just went fed-up
with the first one, (after 7 hours) i just wanted to move on coding, so i went on and did a temporary solution.
And now, another 5 hours later, im posting here...i need help.
I think i could handle the rest, somewhat, if i only got some pointers on how to loop the Strings....
i´m quite new at this and i just can´t find any way to go about it....
ah well..*sighs*
here is the code, so far.....
public class Crypt
{
public static final String MYSTERIOUS_MESSAGE = "Vcpeexb01Ud1ypc1}hrzpeb?";
public static void main(String[] args)
{
String encryptString1 = "A@F";
int firstKey = 113;
Crypto crypto = new Crypto();
crypto.enCrypt(encryptString1, firstKey);
String decryptString1 = MYSTERIOUS_MESSAGE;
int lengthChar1 = MYSTERIOUS_MESSAGE.length();
crypto.deCrypt(decryptString1, lengthChar1);
}
}
class Crypto
{
private int actualKey;
public Crypto()
{
actualKey = 0;
}
public int enCrypt (String encryptString1,int firstKey)
{
this.actualKey = firstKey;
char char0 = encryptString1.charAt(0); //temp solution
char char1 = encryptString1.charAt(1); //temp
char char2 = encryptString1.charAt(2); //temp
char encryptedChar0 = (char)(char0 ^ actualKey); //temp
char encryptedChar1 = (char)(char1 ^ actualKey); //temp
char encryptedChar2 = (char)(char2 ^ actualKey); //temp
String decryptKeyNext = "" + encryptedChar0 + encryptedChar1 + encryptedChar2;
actualKey = Integer.parseInt(decryptKeyNext);
return actualKey;
}
public void deCrypt(String decryptString1,int lengthChar1)
{
for ()
{
for ()
}
}
}
This post has been edited by OrangeSection: 07 October 2008 - 12:36 PM

New Topic/Question
Reply




MultiQuote





|