Verschlüsselungsalgorithmus

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Also ich habe erst begonnen einen kleinen Verschlüsselungsalgorithmus zu coden.
    Dieser Algorithmus soll nach dem Prinzip der Vigenere Verschlüsselung funktionieren.
    Für den Anfang habe ich den Algorithmus ziemlich nunja statisch gehalten der schluessel ist immer der selbe und das "Passwort" auch(zur Kontrolle),
    aber leider funktioniert der Algorithmus noch nicht so wie ich das haben wollte...
    Hier erstmal der Code
    new buchstaben[][] = {
    {" ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"},
    {"A","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"},
    {"B","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A"},
    {"C","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B"},
    {"D","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"},
    {"E","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D"},
    {"F","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E"},
    {"G","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F"},
    {"H","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G"},
    {"I","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H"},
    {"J","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I"},
    {"K","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J"},
    {"L","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K"},
    {"M","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L"},
    {"N","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M"},
    {"O","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N"},
    {"P","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O"},
    {"Q","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"},
    {"R","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q"},
    {"S","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R"},
    {"T","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S"},
    {"U","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T"},
    {"V","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U"},
    {"W","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V"},
    {"X","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W"},
    {"Y","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"},
    {"Z","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y"}
    };
    stock GetChar(string[],stelle)
    {
    new test[2];
    test[0] = string[stelle];
    return test;
    }


    stock verschl(pw[])
    {
    new schluessel[6]="CDEAB";
    while(i<27)
    {
    if(strcmp(GetChar(pw,0),buchstaben[0][i],false)==0)
    {
    while(j<27)
    {
    if(strcmp(GetChar(schluessel,0),buchstaben[j][0],false)==0)
    {
    return printf("%c blub %c blub %s",GetChar(schluessel,0),GetChar(pw,0),buchstaben[j][i]);
    }
    j ++;
    }
    }
    i ++;
    }
    return print("Nichts");
    }
    Wie man sehen kann soll beim erfolgreichen durchführen das 1. Zeichen des Schlüssel, das 1. Zeichen des Passwortes und die Verschlüsselung des 1. Zeichen des Passwortes geprinted werden....das funktioniert auch fast wunderbar nur leider wird der verschlüsselte Buchstabe nicht geprinted aber der Rest schon :huh:
    Die Verwendung des ganzen sieht wie folgt aus

    verschl("HALLO"); // HALLO ist das pw


    Hoffentlich kann mir jmd. sagen wieso der verschlüsselte Buchstabe nicht geprinted wird.
    Ich hoffe ihr habt mein Problem verstanden und, dass mir jmd. helfen kann.


    PS: Ja es ist resourccenfressend aber ich bin Anfänger^^ und das ist Quasi die 0.0000000000000001 Alpha^^

    Einmal editiert, zuletzt von [COE]CodeX ()

  • ich danke für die Hilfe...leider nunja hat es mir nicht geholfen :D
    zu 1.
    Das ich diesen extrem umfrangreichen Array gemacht habe liegt in der Natur der Vigenere Verschlüsselung. Man "erschafft" mehrere Alphabete" und greift auf diese zu...ich weiß nicht wie ich genau im geschriebenen erklären soll wie es funktioniert aber jedenfalls bräuchte man...zumindest laut meiner Denkweise einen 2Dimensionalen Array


    zu 2.
    Wie meinst du das mit dem Abfragen des Charcodes?!

  • Ahhhh! okay jetzt hab ich das mit dem ASCII verstanden...ich wusste die funktionsweise der ASCII Codes schon...nur nicht, dass man das so direkt abfragen kann^^


    Aber irgendwie hilft mir das ganze nicht in meinem sog. Polyalphabet. Ich kann nun zwar viel einfacher an die Buchstaben des PWs und des Schlüssels kommen aber hab leider keine Ahnung wie ich an den neuen Buchstaben aus dem Array komme....

  • Also wenn du was verschlüsseln willst, ich kenne eine sehr einfache Methode :) Noch aus C/C++ Zeiten


    XOR_VALUE(input[],key[],newValue[])
    {
    new j = 0;
    for (new i = 0; i < strlen(input); i++)
    {
    if(j>i)j = 0;
    newValue[i] = (input[i] ^ key[j]);
    }
    }


    Nennt sich wie man sieht XOR, eine sehr bekannte Methode.

    Mfg. BlackFoX_UD_ alias [BFX]Explosion



  • Naja ich wollte halt mal probieren diese Vigenere Methode umzusetzen, weil wir das in der Schule mal etwas ausführlicher hatten aber davon mal abgesehen begreif ich schon das Schnippselchen von dir nicht :S
    Wozu die Abfrage if(j>i)j = 0; ?! j bleibt doch immer 0 und verändert sich nicht oder?