Hey Leute,
ich versuche derzeit eine Cmd-Verschlüsselungssoftware zu schreiben. Habe auch schon ordentlich was geschaftt, aber der Cmd gibt mir immer nur Leerzeichen aus und ich weiß nicht wo der Fehler liegt.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| namespace Key { class Program { static char[] alpha = "abcdefghijklmnopqrstuvwxyz .:,;-?!()".ToCharArray(); static void Main(string[] args) { string stringinput; Console.WriteLine("Geben Sie den zu verschlüsselnen Text ein..."); stringinput = Console.ReadLine(); stringinput = stringinput.ToLower();
double Key; Console.WriteLine("Geben Sie die Verschlüsselung ein..."); Key = Convert.ToDouble(Console.ReadLine());
if (Key > alpha.Length) { Key = Key - (Convert.ToDouble(alpha.Length) * Math.Floor(Key / Convert.ToDouble(alpha.Length))); } if (Key < -alpha.Length) { Key = Key + (Convert.ToDouble(alpha.Length) * Math.Floor(-Key / Convert.ToDouble(alpha.Length))); } char[] charArr = stringinput.ToCharArray(); char[] outputarr = new char[charArr.Length]; outputarr = Verschlüsseln(charArr,Key); Console.WriteLine(outputarr); Console.ReadLine(); }
static char[] Verschlüsseln(char[] input, double key) { char[] output = new char[input.Length]; int x = input.Length; double newindex; for (int j = 0; j < x; j++) { for(int k = 0;k > alpha.Length;k++) { if (input[j].ToString() == alpha[k].ToString()) { newindex = Convert.ToDouble(k) + key; if (newindex > alpha.Length) { newindex -= alpha.Length; } output[j] = alpha[Convert.ToInt32(newindex)]; break; } }
} return output; } }
} |
Achja, ich erhalte keine Fehler-Meldungen nur am Rande
Bedanke mich jetzt schoneinmal für eure Hilfe
Greetz
Moderiert von
Christian S.: C#-Tags hinzugefügt