<?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[Mein Login &amp;amp; Register Code]]></title><description><![CDATA[<p>Hallo Liebe Com,<br />
ich möchte euch heute mein Logincode / Registercode zeigen und fragen, ob ich das villeicht zu kompliziert gemacht habe oder ob es verbesserungs vorschläge gibt.</p>
<p>Ich bin noch Anfänger also bitte nicht soviel Kritik</p>
<blockquote>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

int main(){

	char auswahl;

	cout &lt;&lt; &quot;Zum Login: 1&quot; &lt;&lt; endl;
	cin &gt;&gt; auswahl;
	if (auswahl == '1'){
		login();
	}
	// Registrieren
	// vorherige registration wird überschrieben!
	else if(auswahl == 'r'){
		regi();
	}
}
</code></pre>
</blockquote>
<blockquote>
<p>Datei_Verwaltung.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

string lesenbis1(string dateiname){

	// Dekladieren des Streams
	//
	ifstream datei_lesen;

	// Öffnen des Dekladierten Streams
	//
	datei_lesen.open(dateiname.c_str(), ios::in);
	
	// Fehler überprüfung
	//
	if(!datei_lesen){
		cerr &lt;&lt; &quot;Fataler Fehler.&quot; &lt;&lt; endl;
		exit(0);
	}

	char zeichen;
	string zeichenkette;
	while(!datei_lesen.eof()) {

		datei_lesen.get(zeichen);
		if(zeichen == '@'){
			break;
		}else{
		zeichenkette += zeichen;
		}

	}
	//Stream schließen
	//
	datei_lesen.close();

	return zeichenkette;

}

string lesenbis2(string dateiname){

	// Dekladieren des Streams
	//
	ifstream datei_lesen;

	// Öffnen des Dekladierten Streams
	//
	datei_lesen.open(dateiname.c_str(), ios::in);
	
	// Fehler überprüfung
	//
	if(!datei_lesen){
		cerr &lt;&lt; &quot;Fataler Fehler.&quot; &lt;&lt; endl;
		exit(0);
	}

	char zeichen;
	string zeichenkette;
	int i = 0;
	while(!datei_lesen.eof()) {

		datei_lesen.get(zeichen);

		if (i == 0){
			if(zeichen == '@'){
				i++;
				goto end;
			}else{
				goto end;
			}
		}else if(i == 1){
			if(zeichen != '@'){
				zeichenkette += zeichen;
			}else{
				goto end;
			}
		}
		end:;
	}
	//Stream schließen
	//
	datei_lesen.close();

	return zeichenkette;

}

// NEW
//
void schreibenNew(string in, string dateiname){
	// Name der Datei
	//
	in += '@';

	// Dekladieren des Streams
	//
	ofstream datei_schreiben;

	// Öffnen des Dekladierten Streams
	//
	datei_schreiben.open(dateiname.c_str(), ios::out);

	// Fehler überprüfung
	//
	if(!datei_schreiben){
		cerr &lt;&lt; &quot;Fehler!&quot;;
	}

	// Übergebene Wert Eingabe
	//
	datei_schreiben &lt;&lt; in;

	//Stream schließen
	//
	datei_schreiben.close();

}

// APP
//
void schreibenApp(string in, string dateiname){
	// Name der Datei
	//
	in += '@';

	// Dekladieren des Streams
	//
	ofstream datei_schreiben;

	// Öffnen des Dekladierten Streams
	//
	datei_schreiben.open(dateiname.c_str(), ios::app);

	// Fehler überprüfung
	//
	if(!datei_schreiben){
		cerr &lt;&lt; &quot;Fehler!&quot;;
	}

	// Übergebene Wert Eingabe
	//
	datei_schreiben &lt;&lt; in;

	//Stream schließen
	//
	datei_schreiben.close();

}
</code></pre>
</blockquote>
<blockquote>
<p>login.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

void login(){

	string id, üid;
	string pw, üpw;
	string dateiname = &quot;defuser.txt&quot;;

	cout &lt;&lt; &quot;Dein Username: &quot; &lt;&lt; endl;
	cin &gt;&gt; id;
	cout &lt;&lt; &quot;Dein Passwort: &quot; &lt;&lt; endl;
	cin &gt;&gt; pw;
	pw = md5(pw);
	üid = lesenbis1(dateiname);
	üpw = lesenbis2(dateiname);

	if(id == üid &amp;&amp; pw == üpw){
		cout &lt;&lt; &quot;Login erfolgreich!&quot; &lt;&lt; endl;
		getch();
	}else{
		cout &lt;&lt; &quot;Login Daten Inkorrekt!&quot; &lt;&lt; endl;
		Sleep(1500);
		exit(0);	
	}
}
</code></pre>
</blockquote>
<blockquote>
<p>register.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

struct User {
	string ID;
	string passwort;
	string savegame;
};

void regi(){
	
	User defuser;
	cout &lt;&lt; &quot;Registriere dich bitte!&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Dein Username: &quot;;
	cin &gt;&gt; defuser.ID;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Dein Passwort: &quot;;
	cin &gt;&gt; defuser.passwort;

	defuser.passwort = md5(defuser.passwort);

	defuser.savegame = &quot;defuser.txt&quot;;

	schreibenNew(defuser.ID,defuser.savegame);
	schreibenApp(defuser.passwort,defuser.savegame);

}
</code></pre>
</blockquote>
<blockquote>
<p>overheader.h</p>
<pre><code class="language-cpp">#pragma once

#include &quot;md5.h&quot;
#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;Windows.h&gt;
using namespace std;

// Aus der Datei_Verwaltung.cpp
//

string lesenbis1(string dateiname);
string lesenbis2(string dateiname);

void schreibenNew(string in, string dateiname);
void schreibenApp(string in, string dateiname);

void regi();
void login();
</code></pre>
</blockquote>
<blockquote>
<p>den MD5 CODE habe ich von <a href="http://www.zedwood.com/article/121/cpp-md5-function" rel="nofollow">http://www.zedwood.com/article/121/cpp-md5-function</a></p>
<blockquote>
<p>md5.cpp<br />
/* MD5<br />
converted to C++ class by Frank Thilo (<a href="mailto:thilo@unix-ag.org" rel="nofollow">thilo@unix-ag.org</a>)<br />
for bzflag (<a href="http://www.bzflag.org" rel="nofollow">http://www.bzflag.org</a>)</p>
<p>based on:</p>
<p>md5.h and md5.c<br />
reference implemantion of RFC 1321</p>
<p>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All<br />
rights reserved.</p>
<p>License to copy and use this software is granted provided that it<br />
is identified as the &quot;RSA Data Security, Inc. MD5 Message-Digest<br />
Algorithm&quot; in all material mentioning or referencing this software<br />
or this function.</p>
<p>License is also granted to make and use derivative works provided<br />
that such works are identified as &quot;derived from the RSA Data<br />
Security, Inc. MD5 Message-Digest Algorithm&quot; in all material<br />
mentioning or referencing the derived work.</p>
<p>RSA Data Security, Inc. makes no representations concerning either<br />
the merchantability of this software or the suitability of this<br />
software for any particular purpose. It is provided &quot;as is&quot;<br />
without express or implied warranty of any kind.</p>
<p>These notices must be retained in any copies of any part of this<br />
documentation and/or software.</p>
<p>*/</p>
<p>/* interface header */<br />
#include &quot;md5.h&quot;</p>
<p>/* system implementation headers */<br />
#include &lt;stdio.h&gt;</p>
<p>// Constants for MD5Transform routine.<br />
#define S11 7<br />
#define S12 12<br />
#define S13 17<br />
#define S14 22<br />
#define S21 5<br />
#define S22 9<br />
#define S23 14<br />
#define S24 20<br />
#define S31 4<br />
#define S32 11<br />
#define S33 16<br />
#define S34 23<br />
#define S41 6<br />
#define S42 10<br />
#define S43 15<br />
#define S44 21</p>
<p>///////////////////////////////////////////////</p>
<p>// F, G, H and I are basic MD5 functions.<br />
inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {<br />
return x&amp;y | ~x&amp;z;<br />
}</p>
<p>inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {<br />
return x&amp;z | y&amp;~z;<br />
}</p>
<p>inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {<br />
return x<sup>y</sup>z;<br />
}</p>
<p>inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {<br />
return y ^ (x | ~z);<br />
}</p>
<p>// rotate_left rotates x left n bits.<br />
inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {<br />
return (x &lt;&lt; n) | (x &gt;&gt; (32-n));<br />
}</p>
<p>// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.<br />
// Rotation is separate from addition to prevent recomputation.<br />
inline void MD5::FF(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::GG(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + G(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::HH(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + H(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::II(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + I(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>//////////////////////////////////////////////</p>
<p>// default ctor, just initailize<br />
MD5::MD5()<br />
{<br />
init();<br />
}</p>
<p>//////////////////////////////////////////////</p>
<p>// nifty shortcut ctor, compute MD5 for string and finalize it right away<br />
MD5::MD5(const std::string &amp;text)<br />
{<br />
init();<br />
update(text.c_str(), text.length());<br />
finalize();<br />
}</p>
<p>//////////////////////////////</p>
<p>void MD5::init()<br />
{<br />
finalized=false;</p>
<p>count[0] = 0;<br />
count[1] = 0;</p>
<p>// load magic initialization constants.<br />
state[0] = 0x67452301;<br />
state[1] = 0xefcdab89;<br />
state[2] = 0x98badcfe;<br />
state[3] = 0x10325476;<br />
}</p>
<p>//////////////////////////////</p>
<p>// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.<br />
void MD5::decode(uint4 output[], const uint1 input[], size_type len)<br />
{<br />
for (unsigned int i = 0, j = 0; j &lt; len; i++, j += 4)<br />
output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) &lt;&lt; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--smiling_face_with_sunglasses"
      title="8)"
      alt="😎"
    /> |<br />
(((uint4)input[j+2]) &lt;&lt; 16) | (((uint4)input[j+3]) &lt;&lt; 24);<br />
}</p>
<p>//////////////////////////////</p>
<p>// encodes input (uint4) into output (unsigned char). Assumes len is<br />
// a multiple of 4.<br />
void MD5::encode(uint1 output[], const uint4 input[], size_type len)<br />
{<br />
for (size_type i = 0, j = 0; j &lt; len; i++, j += 4) {<br />
output[j] = input[i] &amp; 0xff;<br />
output[j+1] = (input[i] &gt;&gt; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--smiling_face_with_sunglasses"
      title="8)"
      alt="😎"
    /> &amp; 0xff;<br />
output[j+2] = (input[i] &gt;&gt; 16) &amp; 0xff;<br />
output[j+3] = (input[i] &gt;&gt; 24) &amp; 0xff;<br />
}<br />
}</p>
<p>//////////////////////////////</p>
<p>// apply MD5 algo on a block<br />
void MD5::transform(const uint1 block[blocksize])<br />
{<br />
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];<br />
decode (x, block, blocksize);</p>
<p>/* Round 1 <em>/<br />
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /</em> 1 <em>/<br />
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /</em> 2 <em>/<br />
FF (c, d, a, b, x[ 2], S13, 0x242070db); /</em> 3 <em>/<br />
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /</em> 4 <em>/<br />
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /</em> 5 <em>/<br />
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /</em> 6 <em>/<br />
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /</em> 7 <em>/<br />
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /</em> 8 <em>/<br />
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /</em> 9 <em>/<br />
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /</em> 10 <em>/<br />
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /</em> 11 <em>/<br />
FF (b, c, d, a, x[11], S14, 0x895cd7be); /</em> 12 <em>/<br />
FF (a, b, c, d, x[12], S11, 0x6b901122); /</em> 13 <em>/<br />
FF (d, a, b, c, x[13], S12, 0xfd987193); /</em> 14 <em>/<br />
FF (c, d, a, b, x[14], S13, 0xa679438e); /</em> 15 <em>/<br />
FF (b, c, d, a, x[15], S14, 0x49b40821); /</em> 16 */</p>
<p>/* Round 2 <em>/<br />
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /</em> 17 <em>/<br />
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /</em> 18 <em>/<br />
GG (c, d, a, b, x[11], S23, 0x265e5a51); /</em> 19 <em>/<br />
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /</em> 20 <em>/<br />
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /</em> 21 <em>/<br />
GG (d, a, b, c, x[10], S22, 0x2441453); /</em> 22 <em>/<br />
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /</em> 23 <em>/<br />
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /</em> 24 <em>/<br />
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /</em> 25 <em>/<br />
GG (d, a, b, c, x[14], S22, 0xc33707d6); /</em> 26 <em>/<br />
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /</em> 27 <em>/<br />
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /</em> 28 <em>/<br />
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /</em> 29 <em>/<br />
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /</em> 30 <em>/<br />
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /</em> 31 <em>/<br />
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /</em> 32 */</p>
<p>/* Round 3 <em>/<br />
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /</em> 33 <em>/<br />
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /</em> 34 <em>/<br />
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /</em> 35 <em>/<br />
HH (b, c, d, a, x[14], S34, 0xfde5380c); /</em> 36 <em>/<br />
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /</em> 37 <em>/<br />
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /</em> 38 <em>/<br />
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /</em> 39 <em>/<br />
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /</em> 40 <em>/<br />
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /</em> 41 <em>/<br />
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /</em> 42 <em>/<br />
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /</em> 43 <em>/<br />
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /</em> 44 <em>/<br />
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /</em> 45 <em>/<br />
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /</em> 46 <em>/<br />
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /</em> 47 <em>/<br />
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /</em> 48 */</p>
<p>/* Round 4 <em>/<br />
II (a, b, c, d, x[ 0], S41, 0xf4292244); /</em> 49 <em>/<br />
II (d, a, b, c, x[ 7], S42, 0x432aff97); /</em> 50 <em>/<br />
II (c, d, a, b, x[14], S43, 0xab9423a7); /</em> 51 <em>/<br />
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /</em> 52 <em>/<br />
II (a, b, c, d, x[12], S41, 0x655b59c3); /</em> 53 <em>/<br />
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /</em> 54 <em>/<br />
II (c, d, a, b, x[10], S43, 0xffeff47d); /</em> 55 <em>/<br />
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /</em> 56 <em>/<br />
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /</em> 57 <em>/<br />
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /</em> 58 <em>/<br />
II (c, d, a, b, x[ 6], S43, 0xa3014314); /</em> 59 <em>/<br />
II (b, c, d, a, x[13], S44, 0x4e0811a1); /</em> 60 <em>/<br />
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /</em> 61 <em>/<br />
II (d, a, b, c, x[11], S42, 0xbd3af235); /</em> 62 <em>/<br />
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /</em> 63 <em>/<br />
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /</em> 64 */</p>
<p>state[0] += a;<br />
state[1] += b;<br />
state[2] += c;<br />
state[3] += d;</p>
<p>// Zeroize sensitive information.<br />
memset(x, 0, sizeof x);<br />
}</p>
<p>//////////////////////////////</p>
<p>// MD5 block update operation. Continues an MD5 message-digest<br />
// operation, processing another message block<br />
void MD5::update(const unsigned char input[], size_type length)<br />
{<br />
// compute number of bytes mod 64<br />
size_type index = count[0] / 8 % blocksize;</p>
<p>// Update number of bits<br />
if ((count[0] += (length &lt;&lt; 3)) &lt; (length &lt;&lt; 3))<br />
count[1]++;<br />
count[1] += (length &gt;&gt; 29);</p>
<p>// number of bytes we need to fill in buffer<br />
size_type firstpart = 64 - index;</p>
<p>size_type i;</p>
<p>// transform as many times as possible.<br />
if (length &gt;= firstpart)<br />
{<br />
// fill buffer first, transform<br />
memcpy(&amp;buffer[index], input, firstpart);<br />
transform(buffer);</p>
<p>// transform chunks of blocksize (64 bytes)<br />
for (i = firstpart; i + blocksize &lt;= length; i += blocksize)<br />
transform(&amp;input[i]);</p>
<p>index = 0;<br />
}<br />
else<br />
i = 0;</p>
<p>// buffer remaining input<br />
memcpy(&amp;buffer[index], &amp;input[i], length-i);<br />
}</p>
<p>//////////////////////////////</p>
<p>// for convenience provide a verson with signed char<br />
void MD5::update(const char input[], size_type length)<br />
{<br />
update((const unsigned char*)input, length);<br />
}</p>
<p>//////////////////////////////</p>
<p>// MD5 finalization. Ends an MD5 message-digest operation, writing the<br />
// the message digest and zeroizing the context.<br />
MD5&amp; MD5::finalize()<br />
{<br />
static unsigned char padding[64] = {<br />
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br />
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br />
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0<br />
};</p>
<p>if (!finalized) {<br />
// Save number of bits<br />
unsigned char bits[8];<br />
encode(bits, count, 8);</p>
<p>// pad out to 56 mod 64.<br />
size_type index = count[0] / 8 % 64;<br />
size_type padLen = (index &lt; 56) ? (56 - index) : (120 - index);<br />
update(padding, padLen);</p>
<p>// Append length (before padding)<br />
update(bits, 8);</p>
<p>// Store state in digest<br />
encode(digest, state, 16);</p>
<p>// Zeroize sensitive information.<br />
memset(buffer, 0, sizeof buffer);<br />
memset(count, 0, sizeof count);</p>
<p>finalized=true;<br />
}</p>
<p>return *this;<br />
}</p>
<p>//////////////////////////////</p>
<p>// return hex representation of digest as string<br />
std::string MD5::hexdigest() const<br />
{<br />
if (!finalized)<br />
return &quot;&quot;;</p>
<p>char buf[33];<br />
for (int i=0; i&lt;16; i++)<br />
sprintf(buf+i*2, &quot;%02x&quot;, digest[i]);<br />
buf[32]=0;</p>
<p>return std::string(buf);<br />
}</p>
<p>//////////////////////////////</p>
<p>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, MD5 md5)<br />
{<br />
return out &lt;&lt; md5.hexdigest();<br />
}</p>
<p>//////////////////////////////</p>
<p>std::string md5(const std::string str)<br />
{<br />
MD5 md5 = MD5(str);</p>
<p>return md5.hexdigest();<br />
}</p>
</blockquote>
<blockquote>
<p>md5.h</p>
<blockquote>
<p>/* MD5<br />
converted to C++ class by Frank Thilo (<a href="mailto:thilo@unix-ag.org" rel="nofollow">thilo@unix-ag.org</a>)<br />
for bzflag (<a href="http://www.bzflag.org" rel="nofollow">http://www.bzflag.org</a>)</p>
<p>based on:</p>
<p>md5.h and md5.c<br />
reference implementation of RFC 1321</p>
<p>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All<br />
rights reserved.</p>
<p>License to copy and use this software is granted provided that it<br />
is identified as the &quot;RSA Data Security, Inc. MD5 Message-Digest<br />
Algorithm&quot; in all material mentioning or referencing this software<br />
or this function.</p>
<p>License is also granted to make and use derivative works provided<br />
that such works are identified as &quot;derived from the RSA Data<br />
Security, Inc. MD5 Message-Digest Algorithm&quot; in all material<br />
mentioning or referencing the derived work.</p>
<p>RSA Data Security, Inc. makes no representations concerning either<br />
the merchantability of this software or the suitability of this<br />
software for any particular purpose. It is provided &quot;as is&quot;<br />
without express or implied warranty of any kind.</p>
<p>These notices must be retained in any copies of any part of this<br />
documentation and/or software.</p>
<p>*/</p>
<p>#ifndef BZF_MD5_H<br />
#define BZF_MD5_H</p>
<p>#include &lt;string&gt;<br />
#include &lt;iostream&gt;</p>
<p>// a small class for calculating MD5 hashes of strings or byte arrays<br />
// it is not meant to be fast or secure<br />
//<br />
// usage: 1) feed it blocks of uchars with update()<br />
// 2) finalize()<br />
// 3) get hexdigest() string<br />
// or<br />
// MD5(std::string).hexdigest()<br />
//<br />
// assumes that char is 8 bit and int is 32 bit<br />
class MD5<br />
{<br />
public:<br />
typedef unsigned int size_type; // must be 32bit</p>
<p>MD5();<br />
MD5(const std::string&amp; text);<br />
void update(const unsigned char *buf, size_type length);<br />
void update(const char *buf, size_type length);<br />
MD5&amp; finalize();<br />
std::string hexdigest() const;<br />
friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, MD5 md5);</p>
<p>private:<br />
void init();<br />
typedef unsigned char uint1; // 8bit<br />
typedef unsigned int uint4; // 32bit<br />
enum {blocksize = 64}; // VC6 won't eat a const static int here</p>
<p>void transform(const uint1 block[blocksize]);<br />
static void decode(uint4 output[], const uint1 input[], size_type len);<br />
static void encode(uint1 output[], const uint4 input[], size_type len);</p>
<p>bool finalized;<br />
uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk<br />
uint4 count[2]; // 64bit counter for number of bits (lo, hi)<br />
uint4 state[4]; // digest so far<br />
uint1 digest[16]; // the result</p>
<p>// low level logic operations<br />
static inline uint4 F(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 G(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 H(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 I(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 rotate_left(uint4 x, int n);<br />
static inline void FF(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void GG(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void HH(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void II(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
};</p>
<p>std::string md5(const std::string str);</p>
<p>#endif</p>
</blockquote>
</blockquote>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/topic/287592/mein-login-amp-register-code</link><generator>RSS for Node</generator><lastBuildDate>Thu, 20 Aug 2026 08:44:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/287592.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 31 May 2011 14:19:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:19:46 GMT]]></title><description><![CDATA[<p>Hallo Liebe Com,<br />
ich möchte euch heute mein Logincode / Registercode zeigen und fragen, ob ich das villeicht zu kompliziert gemacht habe oder ob es verbesserungs vorschläge gibt.</p>
<p>Ich bin noch Anfänger also bitte nicht soviel Kritik</p>
<blockquote>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

int main(){

	char auswahl;

	cout &lt;&lt; &quot;Zum Login: 1&quot; &lt;&lt; endl;
	cin &gt;&gt; auswahl;
	if (auswahl == '1'){
		login();
	}
	// Registrieren
	// vorherige registration wird überschrieben!
	else if(auswahl == 'r'){
		regi();
	}
}
</code></pre>
</blockquote>
<blockquote>
<p>Datei_Verwaltung.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

string lesenbis1(string dateiname){

	// Dekladieren des Streams
	//
	ifstream datei_lesen;

	// Öffnen des Dekladierten Streams
	//
	datei_lesen.open(dateiname.c_str(), ios::in);
	
	// Fehler überprüfung
	//
	if(!datei_lesen){
		cerr &lt;&lt; &quot;Fataler Fehler.&quot; &lt;&lt; endl;
		exit(0);
	}

	char zeichen;
	string zeichenkette;
	while(!datei_lesen.eof()) {

		datei_lesen.get(zeichen);
		if(zeichen == '@'){
			break;
		}else{
		zeichenkette += zeichen;
		}

	}
	//Stream schließen
	//
	datei_lesen.close();

	return zeichenkette;

}

string lesenbis2(string dateiname){

	// Dekladieren des Streams
	//
	ifstream datei_lesen;

	// Öffnen des Dekladierten Streams
	//
	datei_lesen.open(dateiname.c_str(), ios::in);
	
	// Fehler überprüfung
	//
	if(!datei_lesen){
		cerr &lt;&lt; &quot;Fataler Fehler.&quot; &lt;&lt; endl;
		exit(0);
	}

	char zeichen;
	string zeichenkette;
	int i = 0;
	while(!datei_lesen.eof()) {

		datei_lesen.get(zeichen);

		if (i == 0){
			if(zeichen == '@'){
				i++;
				goto end;
			}else{
				goto end;
			}
		}else if(i == 1){
			if(zeichen != '@'){
				zeichenkette += zeichen;
			}else{
				goto end;
			}
		}
		end:;
	}
	//Stream schließen
	//
	datei_lesen.close();

	return zeichenkette;

}

// NEW
//
void schreibenNew(string in, string dateiname){
	// Name der Datei
	//
	in += '@';

	// Dekladieren des Streams
	//
	ofstream datei_schreiben;

	// Öffnen des Dekladierten Streams
	//
	datei_schreiben.open(dateiname.c_str(), ios::out);

	// Fehler überprüfung
	//
	if(!datei_schreiben){
		cerr &lt;&lt; &quot;Fehler!&quot;;
	}

	// Übergebene Wert Eingabe
	//
	datei_schreiben &lt;&lt; in;

	//Stream schließen
	//
	datei_schreiben.close();

}

// APP
//
void schreibenApp(string in, string dateiname){
	// Name der Datei
	//
	in += '@';

	// Dekladieren des Streams
	//
	ofstream datei_schreiben;

	// Öffnen des Dekladierten Streams
	//
	datei_schreiben.open(dateiname.c_str(), ios::app);

	// Fehler überprüfung
	//
	if(!datei_schreiben){
		cerr &lt;&lt; &quot;Fehler!&quot;;
	}

	// Übergebene Wert Eingabe
	//
	datei_schreiben &lt;&lt; in;

	//Stream schließen
	//
	datei_schreiben.close();

}
</code></pre>
</blockquote>
<blockquote>
<p>login.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

void login(){

	string id, üid;
	string pw, üpw;
	string dateiname = &quot;defuser.txt&quot;;

	cout &lt;&lt; &quot;Dein Username: &quot; &lt;&lt; endl;
	cin &gt;&gt; id;
	cout &lt;&lt; &quot;Dein Passwort: &quot; &lt;&lt; endl;
	cin &gt;&gt; pw;
	pw = md5(pw);
	üid = lesenbis1(dateiname);
	üpw = lesenbis2(dateiname);

	if(id == üid &amp;&amp; pw == üpw){
		cout &lt;&lt; &quot;Login erfolgreich!&quot; &lt;&lt; endl;
		getch();
	}else{
		cout &lt;&lt; &quot;Login Daten Inkorrekt!&quot; &lt;&lt; endl;
		Sleep(1500);
		exit(0);	
	}
}
</code></pre>
</blockquote>
<blockquote>
<p>register.cpp</p>
<pre><code class="language-cpp">#include &quot;overheader.h&quot;

using namespace std;

struct User {
	string ID;
	string passwort;
	string savegame;
};

void regi(){
	
	User defuser;
	cout &lt;&lt; &quot;Registriere dich bitte!&quot; &lt;&lt; endl;
	cout &lt;&lt; &quot;Dein Username: &quot;;
	cin &gt;&gt; defuser.ID;
	cout &lt;&lt; endl;
	cout &lt;&lt; &quot;Dein Passwort: &quot;;
	cin &gt;&gt; defuser.passwort;

	defuser.passwort = md5(defuser.passwort);

	defuser.savegame = &quot;defuser.txt&quot;;

	schreibenNew(defuser.ID,defuser.savegame);
	schreibenApp(defuser.passwort,defuser.savegame);

}
</code></pre>
</blockquote>
<blockquote>
<p>overheader.h</p>
<pre><code class="language-cpp">#pragma once

#include &quot;md5.h&quot;
#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;string&gt;
#include &lt;fstream&gt;
#include &lt;sstream&gt;
#include &lt;Windows.h&gt;
using namespace std;

// Aus der Datei_Verwaltung.cpp
//

string lesenbis1(string dateiname);
string lesenbis2(string dateiname);

void schreibenNew(string in, string dateiname);
void schreibenApp(string in, string dateiname);

void regi();
void login();
</code></pre>
</blockquote>
<blockquote>
<p>den MD5 CODE habe ich von <a href="http://www.zedwood.com/article/121/cpp-md5-function" rel="nofollow">http://www.zedwood.com/article/121/cpp-md5-function</a></p>
<blockquote>
<p>md5.cpp<br />
/* MD5<br />
converted to C++ class by Frank Thilo (<a href="mailto:thilo@unix-ag.org" rel="nofollow">thilo@unix-ag.org</a>)<br />
for bzflag (<a href="http://www.bzflag.org" rel="nofollow">http://www.bzflag.org</a>)</p>
<p>based on:</p>
<p>md5.h and md5.c<br />
reference implemantion of RFC 1321</p>
<p>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All<br />
rights reserved.</p>
<p>License to copy and use this software is granted provided that it<br />
is identified as the &quot;RSA Data Security, Inc. MD5 Message-Digest<br />
Algorithm&quot; in all material mentioning or referencing this software<br />
or this function.</p>
<p>License is also granted to make and use derivative works provided<br />
that such works are identified as &quot;derived from the RSA Data<br />
Security, Inc. MD5 Message-Digest Algorithm&quot; in all material<br />
mentioning or referencing the derived work.</p>
<p>RSA Data Security, Inc. makes no representations concerning either<br />
the merchantability of this software or the suitability of this<br />
software for any particular purpose. It is provided &quot;as is&quot;<br />
without express or implied warranty of any kind.</p>
<p>These notices must be retained in any copies of any part of this<br />
documentation and/or software.</p>
<p>*/</p>
<p>/* interface header */<br />
#include &quot;md5.h&quot;</p>
<p>/* system implementation headers */<br />
#include &lt;stdio.h&gt;</p>
<p>// Constants for MD5Transform routine.<br />
#define S11 7<br />
#define S12 12<br />
#define S13 17<br />
#define S14 22<br />
#define S21 5<br />
#define S22 9<br />
#define S23 14<br />
#define S24 20<br />
#define S31 4<br />
#define S32 11<br />
#define S33 16<br />
#define S34 23<br />
#define S41 6<br />
#define S42 10<br />
#define S43 15<br />
#define S44 21</p>
<p>///////////////////////////////////////////////</p>
<p>// F, G, H and I are basic MD5 functions.<br />
inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {<br />
return x&amp;y | ~x&amp;z;<br />
}</p>
<p>inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {<br />
return x&amp;z | y&amp;~z;<br />
}</p>
<p>inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {<br />
return x<sup>y</sup>z;<br />
}</p>
<p>inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {<br />
return y ^ (x | ~z);<br />
}</p>
<p>// rotate_left rotates x left n bits.<br />
inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {<br />
return (x &lt;&lt; n) | (x &gt;&gt; (32-n));<br />
}</p>
<p>// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.<br />
// Rotation is separate from addition to prevent recomputation.<br />
inline void MD5::FF(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a+ F(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::GG(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + G(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::HH(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + H(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>inline void MD5::II(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {<br />
a = rotate_left(a + I(b,c,d) + x + ac, s) + b;<br />
}</p>
<p>//////////////////////////////////////////////</p>
<p>// default ctor, just initailize<br />
MD5::MD5()<br />
{<br />
init();<br />
}</p>
<p>//////////////////////////////////////////////</p>
<p>// nifty shortcut ctor, compute MD5 for string and finalize it right away<br />
MD5::MD5(const std::string &amp;text)<br />
{<br />
init();<br />
update(text.c_str(), text.length());<br />
finalize();<br />
}</p>
<p>//////////////////////////////</p>
<p>void MD5::init()<br />
{<br />
finalized=false;</p>
<p>count[0] = 0;<br />
count[1] = 0;</p>
<p>// load magic initialization constants.<br />
state[0] = 0x67452301;<br />
state[1] = 0xefcdab89;<br />
state[2] = 0x98badcfe;<br />
state[3] = 0x10325476;<br />
}</p>
<p>//////////////////////////////</p>
<p>// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.<br />
void MD5::decode(uint4 output[], const uint1 input[], size_type len)<br />
{<br />
for (unsigned int i = 0, j = 0; j &lt; len; i++, j += 4)<br />
output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) &lt;&lt; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--smiling_face_with_sunglasses"
      title="8)"
      alt="😎"
    /> |<br />
(((uint4)input[j+2]) &lt;&lt; 16) | (((uint4)input[j+3]) &lt;&lt; 24);<br />
}</p>
<p>//////////////////////////////</p>
<p>// encodes input (uint4) into output (unsigned char). Assumes len is<br />
// a multiple of 4.<br />
void MD5::encode(uint1 output[], const uint4 input[], size_type len)<br />
{<br />
for (size_type i = 0, j = 0; j &lt; len; i++, j += 4) {<br />
output[j] = input[i] &amp; 0xff;<br />
output[j+1] = (input[i] &gt;&gt; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--smiling_face_with_sunglasses"
      title="8)"
      alt="😎"
    /> &amp; 0xff;<br />
output[j+2] = (input[i] &gt;&gt; 16) &amp; 0xff;<br />
output[j+3] = (input[i] &gt;&gt; 24) &amp; 0xff;<br />
}<br />
}</p>
<p>//////////////////////////////</p>
<p>// apply MD5 algo on a block<br />
void MD5::transform(const uint1 block[blocksize])<br />
{<br />
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];<br />
decode (x, block, blocksize);</p>
<p>/* Round 1 <em>/<br />
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /</em> 1 <em>/<br />
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /</em> 2 <em>/<br />
FF (c, d, a, b, x[ 2], S13, 0x242070db); /</em> 3 <em>/<br />
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /</em> 4 <em>/<br />
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /</em> 5 <em>/<br />
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /</em> 6 <em>/<br />
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /</em> 7 <em>/<br />
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /</em> 8 <em>/<br />
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /</em> 9 <em>/<br />
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /</em> 10 <em>/<br />
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /</em> 11 <em>/<br />
FF (b, c, d, a, x[11], S14, 0x895cd7be); /</em> 12 <em>/<br />
FF (a, b, c, d, x[12], S11, 0x6b901122); /</em> 13 <em>/<br />
FF (d, a, b, c, x[13], S12, 0xfd987193); /</em> 14 <em>/<br />
FF (c, d, a, b, x[14], S13, 0xa679438e); /</em> 15 <em>/<br />
FF (b, c, d, a, x[15], S14, 0x49b40821); /</em> 16 */</p>
<p>/* Round 2 <em>/<br />
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /</em> 17 <em>/<br />
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /</em> 18 <em>/<br />
GG (c, d, a, b, x[11], S23, 0x265e5a51); /</em> 19 <em>/<br />
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /</em> 20 <em>/<br />
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /</em> 21 <em>/<br />
GG (d, a, b, c, x[10], S22, 0x2441453); /</em> 22 <em>/<br />
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /</em> 23 <em>/<br />
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /</em> 24 <em>/<br />
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /</em> 25 <em>/<br />
GG (d, a, b, c, x[14], S22, 0xc33707d6); /</em> 26 <em>/<br />
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /</em> 27 <em>/<br />
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /</em> 28 <em>/<br />
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /</em> 29 <em>/<br />
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /</em> 30 <em>/<br />
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /</em> 31 <em>/<br />
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /</em> 32 */</p>
<p>/* Round 3 <em>/<br />
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /</em> 33 <em>/<br />
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /</em> 34 <em>/<br />
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /</em> 35 <em>/<br />
HH (b, c, d, a, x[14], S34, 0xfde5380c); /</em> 36 <em>/<br />
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /</em> 37 <em>/<br />
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /</em> 38 <em>/<br />
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /</em> 39 <em>/<br />
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /</em> 40 <em>/<br />
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /</em> 41 <em>/<br />
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /</em> 42 <em>/<br />
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /</em> 43 <em>/<br />
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /</em> 44 <em>/<br />
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /</em> 45 <em>/<br />
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /</em> 46 <em>/<br />
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /</em> 47 <em>/<br />
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /</em> 48 */</p>
<p>/* Round 4 <em>/<br />
II (a, b, c, d, x[ 0], S41, 0xf4292244); /</em> 49 <em>/<br />
II (d, a, b, c, x[ 7], S42, 0x432aff97); /</em> 50 <em>/<br />
II (c, d, a, b, x[14], S43, 0xab9423a7); /</em> 51 <em>/<br />
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /</em> 52 <em>/<br />
II (a, b, c, d, x[12], S41, 0x655b59c3); /</em> 53 <em>/<br />
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /</em> 54 <em>/<br />
II (c, d, a, b, x[10], S43, 0xffeff47d); /</em> 55 <em>/<br />
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /</em> 56 <em>/<br />
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /</em> 57 <em>/<br />
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /</em> 58 <em>/<br />
II (c, d, a, b, x[ 6], S43, 0xa3014314); /</em> 59 <em>/<br />
II (b, c, d, a, x[13], S44, 0x4e0811a1); /</em> 60 <em>/<br />
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /</em> 61 <em>/<br />
II (d, a, b, c, x[11], S42, 0xbd3af235); /</em> 62 <em>/<br />
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /</em> 63 <em>/<br />
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /</em> 64 */</p>
<p>state[0] += a;<br />
state[1] += b;<br />
state[2] += c;<br />
state[3] += d;</p>
<p>// Zeroize sensitive information.<br />
memset(x, 0, sizeof x);<br />
}</p>
<p>//////////////////////////////</p>
<p>// MD5 block update operation. Continues an MD5 message-digest<br />
// operation, processing another message block<br />
void MD5::update(const unsigned char input[], size_type length)<br />
{<br />
// compute number of bytes mod 64<br />
size_type index = count[0] / 8 % blocksize;</p>
<p>// Update number of bits<br />
if ((count[0] += (length &lt;&lt; 3)) &lt; (length &lt;&lt; 3))<br />
count[1]++;<br />
count[1] += (length &gt;&gt; 29);</p>
<p>// number of bytes we need to fill in buffer<br />
size_type firstpart = 64 - index;</p>
<p>size_type i;</p>
<p>// transform as many times as possible.<br />
if (length &gt;= firstpart)<br />
{<br />
// fill buffer first, transform<br />
memcpy(&amp;buffer[index], input, firstpart);<br />
transform(buffer);</p>
<p>// transform chunks of blocksize (64 bytes)<br />
for (i = firstpart; i + blocksize &lt;= length; i += blocksize)<br />
transform(&amp;input[i]);</p>
<p>index = 0;<br />
}<br />
else<br />
i = 0;</p>
<p>// buffer remaining input<br />
memcpy(&amp;buffer[index], &amp;input[i], length-i);<br />
}</p>
<p>//////////////////////////////</p>
<p>// for convenience provide a verson with signed char<br />
void MD5::update(const char input[], size_type length)<br />
{<br />
update((const unsigned char*)input, length);<br />
}</p>
<p>//////////////////////////////</p>
<p>// MD5 finalization. Ends an MD5 message-digest operation, writing the<br />
// the message digest and zeroizing the context.<br />
MD5&amp; MD5::finalize()<br />
{<br />
static unsigned char padding[64] = {<br />
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br />
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,<br />
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0<br />
};</p>
<p>if (!finalized) {<br />
// Save number of bits<br />
unsigned char bits[8];<br />
encode(bits, count, 8);</p>
<p>// pad out to 56 mod 64.<br />
size_type index = count[0] / 8 % 64;<br />
size_type padLen = (index &lt; 56) ? (56 - index) : (120 - index);<br />
update(padding, padLen);</p>
<p>// Append length (before padding)<br />
update(bits, 8);</p>
<p>// Store state in digest<br />
encode(digest, state, 16);</p>
<p>// Zeroize sensitive information.<br />
memset(buffer, 0, sizeof buffer);<br />
memset(count, 0, sizeof count);</p>
<p>finalized=true;<br />
}</p>
<p>return *this;<br />
}</p>
<p>//////////////////////////////</p>
<p>// return hex representation of digest as string<br />
std::string MD5::hexdigest() const<br />
{<br />
if (!finalized)<br />
return &quot;&quot;;</p>
<p>char buf[33];<br />
for (int i=0; i&lt;16; i++)<br />
sprintf(buf+i*2, &quot;%02x&quot;, digest[i]);<br />
buf[32]=0;</p>
<p>return std::string(buf);<br />
}</p>
<p>//////////////////////////////</p>
<p>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, MD5 md5)<br />
{<br />
return out &lt;&lt; md5.hexdigest();<br />
}</p>
<p>//////////////////////////////</p>
<p>std::string md5(const std::string str)<br />
{<br />
MD5 md5 = MD5(str);</p>
<p>return md5.hexdigest();<br />
}</p>
</blockquote>
<blockquote>
<p>md5.h</p>
<blockquote>
<p>/* MD5<br />
converted to C++ class by Frank Thilo (<a href="mailto:thilo@unix-ag.org" rel="nofollow">thilo@unix-ag.org</a>)<br />
for bzflag (<a href="http://www.bzflag.org" rel="nofollow">http://www.bzflag.org</a>)</p>
<p>based on:</p>
<p>md5.h and md5.c<br />
reference implementation of RFC 1321</p>
<p>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All<br />
rights reserved.</p>
<p>License to copy and use this software is granted provided that it<br />
is identified as the &quot;RSA Data Security, Inc. MD5 Message-Digest<br />
Algorithm&quot; in all material mentioning or referencing this software<br />
or this function.</p>
<p>License is also granted to make and use derivative works provided<br />
that such works are identified as &quot;derived from the RSA Data<br />
Security, Inc. MD5 Message-Digest Algorithm&quot; in all material<br />
mentioning or referencing the derived work.</p>
<p>RSA Data Security, Inc. makes no representations concerning either<br />
the merchantability of this software or the suitability of this<br />
software for any particular purpose. It is provided &quot;as is&quot;<br />
without express or implied warranty of any kind.</p>
<p>These notices must be retained in any copies of any part of this<br />
documentation and/or software.</p>
<p>*/</p>
<p>#ifndef BZF_MD5_H<br />
#define BZF_MD5_H</p>
<p>#include &lt;string&gt;<br />
#include &lt;iostream&gt;</p>
<p>// a small class for calculating MD5 hashes of strings or byte arrays<br />
// it is not meant to be fast or secure<br />
//<br />
// usage: 1) feed it blocks of uchars with update()<br />
// 2) finalize()<br />
// 3) get hexdigest() string<br />
// or<br />
// MD5(std::string).hexdigest()<br />
//<br />
// assumes that char is 8 bit and int is 32 bit<br />
class MD5<br />
{<br />
public:<br />
typedef unsigned int size_type; // must be 32bit</p>
<p>MD5();<br />
MD5(const std::string&amp; text);<br />
void update(const unsigned char *buf, size_type length);<br />
void update(const char *buf, size_type length);<br />
MD5&amp; finalize();<br />
std::string hexdigest() const;<br />
friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, MD5 md5);</p>
<p>private:<br />
void init();<br />
typedef unsigned char uint1; // 8bit<br />
typedef unsigned int uint4; // 32bit<br />
enum {blocksize = 64}; // VC6 won't eat a const static int here</p>
<p>void transform(const uint1 block[blocksize]);<br />
static void decode(uint4 output[], const uint1 input[], size_type len);<br />
static void encode(uint1 output[], const uint4 input[], size_type len);</p>
<p>bool finalized;<br />
uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk<br />
uint4 count[2]; // 64bit counter for number of bits (lo, hi)<br />
uint4 state[4]; // digest so far<br />
uint1 digest[16]; // the result</p>
<p>// low level logic operations<br />
static inline uint4 F(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 G(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 H(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 I(uint4 x, uint4 y, uint4 z);<br />
static inline uint4 rotate_left(uint4 x, int n);<br />
static inline void FF(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void GG(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void HH(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
static inline void II(uint4 &amp;a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);<br />
};</p>
<p>std::string md5(const std::string str);</p>
<p>#endif</p>
</blockquote>
</blockquote>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2071492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071492</guid><dc:creator><![CDATA[lilbeat]]></dc:creator><pubDate>Tue, 31 May 2011 14:19:46 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:31:10 GMT]]></title><description><![CDATA[<p>Niemand liest sich so etwas durch, wenn du nicht eine konkrete Frage zu überschaubar viel Code hast.</p>
<p>Nur so viel: Ein Header für alles ist nicht die richtige Idee zur Benutzung von Headern. Und ein using namespace std; im Header gehört auch verboten, erst recht in so einem mächtigen Header.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071501</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 31 May 2011 14:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:32:27 GMT]]></title><description><![CDATA[<p>Ja tut mir leid ich wollte mir das programmieren etwas erleichtern ..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071502</guid><dc:creator><![CDATA[lilbeat]]></dc:creator><pubDate>Tue, 31 May 2011 14:32:27 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:36:09 GMT]]></title><description><![CDATA[<p>Man kann's mit den Kommentaren auch übertreiben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071505</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Tue, 31 May 2011 14:36:09 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:39:21 GMT]]></title><description><![CDATA[<p>:o o.O<br />
okee .. zuviel kommentare?^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071507</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071507</guid><dc:creator><![CDATA[lilbeat]]></dc:creator><pubDate>Tue, 31 May 2011 14:39:21 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:43:50 GMT]]></title><description><![CDATA[<p>lilbeat schrieb:</p>
<blockquote>
<p>:o o.O<br />
okee .. zuviel kommentare?^^</p>
</blockquote>
<p>Ja. Beispiel: jeder, der deinen Code liest, was ein Nullen per memset ist. Das braucht keine Erklärung. Genauso sind Sachen wie &quot;Stream schließen&quot; unnötig, wenn der Aufruf sowas wie <code>stream.close()</code> ist.^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071511</guid><dc:creator><![CDATA[_matze]]></dc:creator><pubDate>Tue, 31 May 2011 14:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 14:52:33 GMT]]></title><description><![CDATA[<p>nur ein paar sachen<br />
1. Übergib sowas wie string als konstante referenz an deine funktion<br />
2. Es heißt deklarieren, nicht dekladieren<br />
3. wenn du einen if/of-stream deklariest, kannst du den Dateinamen im Konstruktor übergeben (anstatt open aufzurufen). Genauso konnst du auf close verzichten, da der stream beim beenden der funktion eh zerstört wird.<br />
4. Du könntest nach der Benutzereingabe prüfen, ob std::cin noch gültig ist (if(!std::cin)) [immerhin ließt du nur in einen char ein, der benutzer könnte alles eingeben]. Ähnlich dazu musst du in deiner while schleife nicht gegen streamname.eof() testen, sondern kannst gleich auf die Gültigkeit des Streams testen: while(!streamname)<br />
5. Vermeide goto! in deinem Fall könntest du einfach return zeichenkette schreiben.<br />
6. In deiner Login-Funktion: Warum die strings alle am anfang deklarieren und nicht warten, bis sie gebraucht werden?<br />
7. Vermeide getch()! Nimm lieber std::cin.get() [oder guck in die FAQ, was es da noch so gibt]. Für Sleep gilt das selbe (alles Windows-spezifische Funktionen) -&gt; dann brauchst du auch windows.h nicht mehr zu inkludieren.</p>
<p>Das ist mir beim schnellen Überfliegen aufgefallen. Vielleicht nicht alles sinnvoll, aber er kann sich ja ein eigenes Bild machen :&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071516</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071516</guid><dc:creator><![CDATA[asdfasd]]></dc:creator><pubDate>Tue, 31 May 2011 14:52:33 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 15:44:46 GMT]]></title><description><![CDATA[<p>ich danke für eure hilfreichen, aufschlussreichen und lehrreichen kommentare zu meinem kleinem program <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 />
kannst du mir bitte eine alternative zu sleep() nennen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071539</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071539</guid><dc:creator><![CDATA[lilbeat]]></dc:creator><pubDate>Tue, 31 May 2011 15:44:46 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 16:06:33 GMT]]></title><description><![CDATA[<p>lilbeat schrieb:</p>
<blockquote>
<p>kannst du mir bitte eine alternative zu sleep() nennen?</p>
</blockquote>
<p>Kein Sleep verwenden? Wozu auch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071551</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 31 May 2011 16:06:33 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 16:09:03 GMT]]></title><description><![CDATA[<p>lilbeat schrieb:</p>
<blockquote>
<p>ich danke für eure hilfreichen, aufschlussreichen und lehrreichen kommentare zu meinem kleinem program <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 />
kannst du mir bitte eine alternative zu sleep() nennen?</p>
</blockquote>
<p>Gibt keine Alternative - die Frage ist, wozu brauchst du dort ein sleep? Völlig unnötig.</p>
<p>P.S.: Zu langsam <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071554</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071554</guid><dc:creator><![CDATA[inter2k3]]></dc:creator><pubDate>Tue, 31 May 2011 16:09:03 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 18:29:40 GMT]]></title><description><![CDATA[<p>Naja, du könntest zum Beispiel die Zeit des letzen Loginveruchs speichern und den nächsten login einfach verwähren (wenn du da eine Zeitsperre einbauen willst).<br />
siehe -&gt; &lt;ctime&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071663</guid><dc:creator><![CDATA[asdfasd]]></dc:creator><pubDate>Tue, 31 May 2011 18:29:40 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Tue, 31 May 2011 18:53:21 GMT]]></title><description><![CDATA[<p>als warten befehl .. zb wenn ich ein text adventure schreiben will indem man dann 60 sek lang arbeitet usw</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071686</guid><dc:creator><![CDATA[lilbeat]]></dc:creator><pubDate>Tue, 31 May 2011 18:53:21 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Login &amp;amp; Register Code on Wed, 01 Jun 2011 08:48:45 GMT]]></title><description><![CDATA[<p>lilbeat schrieb:</p>
<blockquote>
<p>Ja tut mir leid ich wollte mir das programmieren etwas erleichtern ..</p>
</blockquote>
<p>OOP muss her!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2071889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2071889</guid><dc:creator><![CDATA[*Rewind*]]></dc:creator><pubDate>Wed, 01 Jun 2011 08:48:45 GMT</pubDate></item></channel></rss>