I have to create a program that decrypts the message :mmZ\dxZmx]Zpgy
the encryption method is ASCII code.
This should be all that I need but im getting an incompatible type error
here:
char encrypted[]= "(:mmZ\\dxZmx]Zpgy)";
I know that technically its a string but I couldn't think of any other way of doing this.. here is my entire code
package decrypt;
public class Decrypt
{
public static void decrypt(char encrypted[], int key)
{
System.out.println(key + ": ");
for (int i=0; i < encrypted.length; i++)
{
char originalChar = encrypted[i];
char encryptedChar;
if ((originalChar -key) < 32)
encryptedChar = (char) (originalChar - 32 + 127 -key);
else
encryptedChar = (char) (originalChar -key);
System.out.println(encryptedChar);
}
}
public static void main(String[] args)
{
char encrypted[]= "(:mmZ\\dxZmx]Zpgy)";
for (int i=1; i <=100; i++)
{
decrypt(encrypted, i);
}
}
}