<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Crypto Algo Absturz]]></title><description><![CDATA[<p>Hallo,<br />
evtl kann mir ja jemand helfen ist jetzt 3:21 muss morgen raus *g*<br />
hab ein paar probleme ich vermute das die sbox Funktion irgendwie überläuft.<br />
sehe vor lauter Code nichts mehr.<br />
habe die ganze Sache hier mal provisorisch aufgebaut <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Gruß tom.</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;fstream.h&gt;

#define PASSLEN 60              //beide bei 70 wegen schleife 0
#define STRINGLEN 60

unsigned char key[60];        //71 byte haben platz
//---------------------------------------------------------------------------
void sbox(char *box);
void crypt(unsigned char *passwort, unsigned char *string, int stringlen);
void fullstring(unsigned char *string);
//---------------------------------------------------------------------------
int main()
{
fstream keyfile(&quot;key.txt&quot;, ios::in|ios::out|ios::binary );
keyfile.getline(key,61); //schlussel laden
keyfile.close();

int stringlen = 0;

sbox(key);
unsigned char test[STRINGLEN];
stringlen = strlen(test);
strcpy(test, &quot;hallo lalelo 123&quot;);
fullstring(test);
crypt(key, test, STRINGLEN);

//entschlusseln
fstream keyfile2(&quot;key.txt&quot;, ios::in|ios::out|ios::binary );
keyfile2.getline(key,61); //schlussel laden
keyfile2.close();
sbox(key);
crypt(key, test, STRINGLEN);
cout &lt;&lt; &quot;Entschlusselt :&quot; &lt;&lt; test;

return 0;
}

void sbox(char *box)
{
int posB;                     //posB position fur B
int round = 65;              //zudruchlaufende runden
int i;                       //schleifen durchlauf
int rest;                    //restwert modulus nur temp
char a, b;                   //zuaddierende zeichen

    for(int counter = 0; counter &lt;= PASSLEN; counter ++)//lese erstes zeichen
    {
      a = box[counter];                                 //sichere zeichen
      posB = box[counter];                              //wert in dezimal wandeln
      //posB += 1;                                      //null byte irgendwie vermeiden
      rest = posB % PASSLEN;                            //restwert ermitteln
      posB = rest;                                      //restwert ist position im string
      for(i = 1; i &lt;= round; i++)                       //jedes zeichen wird 64 verschluselungen durchfuhren
      {
        b = box[posB];                                  //position b speichern
        box[posB] ^= a;                                 //positon b mit a verschlusseln
        posB = b;                                       //wert b in dezimal wandeln
        //posB += 1;                                    //null byte irgendwie vermeiden
        rest = posB % PASSLEN;                          //restwert ermitteln
        posB = rest;                                    //restwert ist neue position von b im string
      }
   }
}

void crypt(unsigned char *passwort, unsigned char *string, int stringlen)
{
    if( stringlen &lt;= 0 ) return;                  // Wenn &lt;= 0 Function beenden

    int curpasscharpos = 0;                       // Aktuelle Position im Passwort damit wir wissen mit welchen Zeichen wir verschlüsseln

    for( int i = 0; i &lt; stringlen; i++){          // solange durchlaufen bis jedes Zeichen des Strings verschlüsselt wurde
        string[i] ^= passwort[curpasscharpos];    // xor
        if( ++curpasscharpos &gt;= PASSLEN )         // erhöhen der Position im Passwort und wenn die &gt; als die länge dessen ist
            curpasscharpos = 0;                   // fangen wir wieder vorn an
    }
}

void fullstring(unsigned char *string)
{
  int stringlen = strlen(string);                   //lange des strings
  int miss = PASSLEN - stringlen;
    for( int i = 0; i &lt;= miss; i++)
    {
    strcat(string, &quot;_&quot;);
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/194527/crypto-algo-absturz</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 14:17:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/194527.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Oct 2007 01:26:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Crypto Algo Absturz on Mon, 08 Oct 2007 01:27:07 GMT]]></title><description><![CDATA[<p>Hallo,<br />
evtl kann mir ja jemand helfen ist jetzt 3:21 muss morgen raus *g*<br />
hab ein paar probleme ich vermute das die sbox Funktion irgendwie überläuft.<br />
sehe vor lauter Code nichts mehr.<br />
habe die ganze Sache hier mal provisorisch aufgebaut <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Gruß tom.</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;fstream.h&gt;

#define PASSLEN 60              //beide bei 70 wegen schleife 0
#define STRINGLEN 60

unsigned char key[60];        //71 byte haben platz
//---------------------------------------------------------------------------
void sbox(char *box);
void crypt(unsigned char *passwort, unsigned char *string, int stringlen);
void fullstring(unsigned char *string);
//---------------------------------------------------------------------------
int main()
{
fstream keyfile(&quot;key.txt&quot;, ios::in|ios::out|ios::binary );
keyfile.getline(key,61); //schlussel laden
keyfile.close();

int stringlen = 0;

sbox(key);
unsigned char test[STRINGLEN];
stringlen = strlen(test);
strcpy(test, &quot;hallo lalelo 123&quot;);
fullstring(test);
crypt(key, test, STRINGLEN);

//entschlusseln
fstream keyfile2(&quot;key.txt&quot;, ios::in|ios::out|ios::binary );
keyfile2.getline(key,61); //schlussel laden
keyfile2.close();
sbox(key);
crypt(key, test, STRINGLEN);
cout &lt;&lt; &quot;Entschlusselt :&quot; &lt;&lt; test;

return 0;
}

void sbox(char *box)
{
int posB;                     //posB position fur B
int round = 65;              //zudruchlaufende runden
int i;                       //schleifen durchlauf
int rest;                    //restwert modulus nur temp
char a, b;                   //zuaddierende zeichen

    for(int counter = 0; counter &lt;= PASSLEN; counter ++)//lese erstes zeichen
    {
      a = box[counter];                                 //sichere zeichen
      posB = box[counter];                              //wert in dezimal wandeln
      //posB += 1;                                      //null byte irgendwie vermeiden
      rest = posB % PASSLEN;                            //restwert ermitteln
      posB = rest;                                      //restwert ist position im string
      for(i = 1; i &lt;= round; i++)                       //jedes zeichen wird 64 verschluselungen durchfuhren
      {
        b = box[posB];                                  //position b speichern
        box[posB] ^= a;                                 //positon b mit a verschlusseln
        posB = b;                                       //wert b in dezimal wandeln
        //posB += 1;                                    //null byte irgendwie vermeiden
        rest = posB % PASSLEN;                          //restwert ermitteln
        posB = rest;                                    //restwert ist neue position von b im string
      }
   }
}

void crypt(unsigned char *passwort, unsigned char *string, int stringlen)
{
    if( stringlen &lt;= 0 ) return;                  // Wenn &lt;= 0 Function beenden

    int curpasscharpos = 0;                       // Aktuelle Position im Passwort damit wir wissen mit welchen Zeichen wir verschlüsseln

    for( int i = 0; i &lt; stringlen; i++){          // solange durchlaufen bis jedes Zeichen des Strings verschlüsselt wurde
        string[i] ^= passwort[curpasscharpos];    // xor
        if( ++curpasscharpos &gt;= PASSLEN )         // erhöhen der Position im Passwort und wenn die &gt; als die länge dessen ist
            curpasscharpos = 0;                   // fangen wir wieder vorn an
    }
}

void fullstring(unsigned char *string)
{
  int stringlen = strlen(string);                   //lange des strings
  int miss = PASSLEN - stringlen;
    for( int i = 0; i &lt;= miss; i++)
    {
    strcat(string, &quot;_&quot;);
    }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1380176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380176</guid><dc:creator><![CDATA[kronos33]]></dc:creator><pubDate>Mon, 08 Oct 2007 01:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to Crypto Algo Absturz on Mon, 08 Oct 2007 04:42:29 GMT]]></title><description><![CDATA[<p>ohne es genau anzuschauen würde ich hier auf das &lt;= tippen</p>
<pre><code class="language-cpp">for(int counter = 0; counter &lt;= PASSLEN; counter ++)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1380181</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380181</guid><dc:creator><![CDATA[hereigo]]></dc:creator><pubDate>Mon, 08 Oct 2007 04:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to Crypto Algo Absturz on Mon, 08 Oct 2007 04:51:58 GMT]]></title><description><![CDATA[<p>genau:</p>
<pre><code class="language-cpp">for(int counter = 0; counter &lt;= PASSLEN; counter ++)
</code></pre>
<p>Druch das &quot;&lt;=&quot; greifst du auf den Index 60 von &quot;box&quot; zu! Indexarea out of bounce! mach ein &quot;&lt;&quot; draus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380182</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Mon, 08 Oct 2007 04:51:58 GMT</pubDate></item><item><title><![CDATA[Reply to Crypto Algo Absturz on Mon, 08 Oct 2007 05:39:39 GMT]]></title><description><![CDATA[<p>Nur mal am Rande:</p>
<p>kronos33 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">#define PASSLEN 60              //beide bei 70 wegen schleife 0
#define STRINGLEN 60

unsigned char key[60];        //71 byte haben platz
}
</code></pre>
</blockquote>
<p>Hast du mal darüber nachgedacht, wie weit deine Kommentare noch zum Quelltext passen?</p>
<p>(außerdem solltest du beim Umgang mit C-Strings daran denken, immer ein Byte extra für den Null-Terminator bereitzustellen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1380191</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1380191</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 08 Oct 2007 05:39:39 GMT</pubDate></item></channel></rss>