Decrypt caesar cipher

thank you thank you very much

I change to this and it seems to work:
cBuchstabe = shift(previous, N_MAX_CHARS-move);

I have modified your code a little bit, specifically I removed the bulky array and did a simple substitution. Full code below.


final int N_MAX_CHARS=26;

String eingabeText = "katze";
String geheimText;                       
String entEingabeText = "";              
int schluessel = 3;  //Caesar cipher key

void setup(){
  code();        
  entEingabeText = decode(geheimText, schluessel);      
  println("eingabeText: " + eingabeText);
  println("geheimText: " + geheimText);
  println("entschlüsselter Text: " + entEingabeText);
}

void code(){
  char cBuchstabe;              
  geheimText = "";              

  for (int i=0; i < eingabeText.length(); i++)
  {

    char next = eingabeText.charAt(i);            
    cBuchstabe = shift(next, schluessel);          
    geheimText = geheimText + cBuchstabe;
  }
  println(eingabeText, "=>", geheimText);
}

String decode(String iGeheim, int move){
  char cBuchstabe;
  String oKlartext = "";
  for (int i=0; i < eingabeText.length(); i++)
  {
    char previous = geheimText.charAt(i);
    cBuchstabe = shift(previous, N_MAX_CHARS-move);
    oKlartext = oKlartext + cBuchstabe;
  }
  return oKlartext;
}                                         

char shift(char buchstabe, int move){
  int j = 0;              
  int pos = 0; 

  j=buchstabe-'a';
  pos = (j+move)%N_MAX_CHARS; 

  char newBuchstabe = char(pos+'a');    
  println(buchstabe, "=>", newBuchstabe);
  return newBuchstabe;
}