<?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[Function verändern]]></title><description><![CDATA[<p>hi leute,<br />
ich habe diese function hier:</p>
<pre><code>void encrypt(FILE *in, FILE *out, enum modeOfOperation mode)
{
    /* the non-expanded keySize */
    enum keySize size = SIZE_32;

    /* the AES input/output */
    unsigned char plaintext[16] = {0};
    unsigned char input[16] = {0};
    unsigned char output[16] = {0};
    unsigned char ciphertext[16] = {0};
    unsigned char IV[16] = {0};

    /* the AES key */
    unsigned char key[32] = {0x0};

    /* char firstRound */
    char firstRound = 1;

    long int fileSize;
    size_t read;
    int i;

    if (in != NULL)
    {
        fseek(in,0,SEEK_END);
        fileSize = ftell(in);
        fseek(in,0,SEEK_SET);

        /* add the file header */
        fwrite(&amp;mode, sizeof(mode), 1, out);
        fwrite(&amp;fileSize, sizeof(fileSize), 1, out);

        while ((read = fread(plaintext, sizeof(unsigned char), 16, in)) &gt; 0)
        {
            if (mode == OFB)
            {
                if (firstRound)
                {
                    aes_encrypt(IV, output, key, size);
                    firstRound = 0;
                }
                else
                {
                    aes_encrypt(input, output, key, size);
                }
                for (i = 0; i &lt; 16; i++)
                {
                    ciphertext[i] = plaintext[i] ^ output[i];
                }
                fwrite(ciphertext, sizeof(unsigned char), read, out);
                memcpy(input, output, 16*sizeof(unsigned char));
            }

        }
    }
}
</code></pre>
<p>wie ihr seht, benutzt die function als eingang eine datei und als ausgang auch,<br />
jetzt will ich aber machen das der unput ein char array ist und der output auch,<br />
also etwa so :</p>
<p>functio(char input){<br />
return output;<br />
}</p>
<p>Mfg Lukas3</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/204640/function-verändern</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 16:27:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/204640.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Feb 2008 16:29:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Function verändern on Tue, 05 Feb 2008 16:29:50 GMT]]></title><description><![CDATA[<p>hi leute,<br />
ich habe diese function hier:</p>
<pre><code>void encrypt(FILE *in, FILE *out, enum modeOfOperation mode)
{
    /* the non-expanded keySize */
    enum keySize size = SIZE_32;

    /* the AES input/output */
    unsigned char plaintext[16] = {0};
    unsigned char input[16] = {0};
    unsigned char output[16] = {0};
    unsigned char ciphertext[16] = {0};
    unsigned char IV[16] = {0};

    /* the AES key */
    unsigned char key[32] = {0x0};

    /* char firstRound */
    char firstRound = 1;

    long int fileSize;
    size_t read;
    int i;

    if (in != NULL)
    {
        fseek(in,0,SEEK_END);
        fileSize = ftell(in);
        fseek(in,0,SEEK_SET);

        /* add the file header */
        fwrite(&amp;mode, sizeof(mode), 1, out);
        fwrite(&amp;fileSize, sizeof(fileSize), 1, out);

        while ((read = fread(plaintext, sizeof(unsigned char), 16, in)) &gt; 0)
        {
            if (mode == OFB)
            {
                if (firstRound)
                {
                    aes_encrypt(IV, output, key, size);
                    firstRound = 0;
                }
                else
                {
                    aes_encrypt(input, output, key, size);
                }
                for (i = 0; i &lt; 16; i++)
                {
                    ciphertext[i] = plaintext[i] ^ output[i];
                }
                fwrite(ciphertext, sizeof(unsigned char), read, out);
                memcpy(input, output, 16*sizeof(unsigned char));
            }

        }
    }
}
</code></pre>
<p>wie ihr seht, benutzt die function als eingang eine datei und als ausgang auch,<br />
jetzt will ich aber machen das der unput ein char array ist und der output auch,<br />
also etwa so :</p>
<p>functio(char input){<br />
return output;<br />
}</p>
<p>Mfg Lukas3</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1449932</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1449932</guid><dc:creator><![CDATA[Lukas3]]></dc:creator><pubDate>Tue, 05 Feb 2008 16:29:50 GMT</pubDate></item><item><title><![CDATA[Reply to Function verändern on Tue, 05 Feb 2008 16:55:14 GMT]]></title><description><![CDATA[<p>Könnte es sein das du C und nicht C++ haben willst?</p>
<p>Ansonsten würde ich dir eh raten mit std::string zu arbeiten und die Funktion in der folgenden Form umzusetzen:</p>
<pre><code class="language-cpp">std::string funktion(const std::string);
</code></pre>
<p>Wenn du mit C-Strings (char*/char[]) arbeitest ist es besser sowohl den Ausgabepuffer wie auch den Eingabepuffer zu übergeben, da du sonst in der Funktion Speicher allozieren musst den du außerhalb freigeben müsstest.</p>
<p>In dem Fall wäre</p>
<pre><code class="language-cpp">void funktion(char*, char*)
</code></pre>
<p>der Funktion</p>
<pre><code class="language-cpp">char* funktion(char*)
</code></pre>
<p>vorzuziehen!</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1449953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1449953</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Tue, 05 Feb 2008 16:55:14 GMT</pubDate></item></channel></rss>