Wie erstelle ich einen MD5-Hash aus einem String in Code::Blocks (MinGW) (GELÖST)
-
^^ ach so, die funktion 'MDString' schmeiss raus, ist uralt-stil und wird sowieso nicht gebraucht.

-
hi ;fricky
danke für den code...
funktioniert nur leider nicht

mal wieder millionen von fehler...
main.cpp|139|error: variable or field `MD5Init' declared void| main.cpp|139|error: `mdContext' was not declared in this scope| main.cpp|140|error: expected `,' or `;' before "MD5_CTX"| main.cpp|141|error: expected unqualified-id before '{' token| main.cpp||In function `void MD5Update(MD5_CTX*, unsigned char*, unsigned int)':| main.cpp|94|error: too many arguments to function `void Transform()'| main.cpp|178|error: at this point in file| main.cpp||In function `void MD5Final(MD5_CTX*)':| main.cpp|94|error: too many arguments to function `void Transform()'| main.cpp|208|error: at this point in file| main.cpp||In function `void Transform(UINT4*, UINT4*)':| main.cpp|233|warning: this decimal constant is unsigned only in ISO C90| main.cpp|234|warning: this decimal constant is unsigned only in ISO C90| main.cpp|236|warning: this decimal constant is unsigned only in ISO C90| main.cpp|237|warning: this decimal constant is unsigned only in ISO C90| main.cpp|239|warning: this decimal constant is unsigned only in ISO C90| main.cpp|240|warning: this decimal constant is unsigned only in ISO C90| main.cpp|242|warning: this decimal constant is unsigned only in ISO C90| main.cpp|243|warning: this decimal constant is unsigned only in ISO C90| main.cpp|244|warning: this decimal constant is unsigned only in ISO C90| main.cpp|246|warning: this decimal constant is unsigned only in ISO C90| main.cpp|247|warning: this decimal constant is unsigned only in ISO C90| main.cpp|255|warning: this decimal constant is unsigned only in ISO C90| main.cpp|256|warning: this decimal constant is unsigned only in ISO C90| main.cpp|258|warning: this decimal constant is unsigned only in ISO C90| main.cpp|259|warning: this decimal constant is unsigned only in ISO C90| main.cpp|261|warning: this decimal constant is unsigned only in ISO C90| main.cpp|262|warning: this decimal constant is unsigned only in ISO C90| main.cpp|264|warning: this decimal constant is unsigned only in ISO C90| main.cpp|265|warning: this decimal constant is unsigned only in ISO C90| main.cpp|267|warning: this decimal constant is unsigned only in ISO C90| main.cpp|268|warning: this decimal constant is unsigned only in ISO C90| main.cpp|270|warning: this decimal constant is unsigned only in ISO C90| main.cpp|277|warning: this decimal constant is unsigned only in ISO C90| main.cpp|278|warning: this decimal constant is unsigned only in ISO C90| main.cpp|280|warning: this decimal constant is unsigned only in ISO C90| main.cpp|281|warning: this decimal constant is unsigned only in ISO C90| main.cpp|283|warning: this decimal constant is unsigned only in ISO C90| main.cpp|284|warning: this decimal constant is unsigned only in ISO C90| main.cpp|286|warning: this decimal constant is unsigned only in ISO C90| main.cpp|287|warning: this decimal constant is unsigned only in ISO C90| main.cpp|289|warning: this decimal constant is unsigned only in ISO C90| main.cpp|290|warning: this decimal constant is unsigned only in ISO C90| main.cpp|292|warning: this decimal constant is unsigned only in ISO C90| main.cpp|299|warning: this decimal constant is unsigned only in ISO C90| main.cpp|301|warning: this decimal constant is unsigned only in ISO C90| main.cpp|302|warning: this decimal constant is unsigned only in ISO C90| main.cpp|304|warning: this decimal constant is unsigned only in ISO C90| main.cpp|305|warning: this decimal constant is unsigned only in ISO C90| main.cpp|306|warning: this decimal constant is unsigned only in ISO C90| main.cpp|308|warning: this decimal constant is unsigned only in ISO C90| main.cpp|309|warning: this decimal constant is unsigned only in ISO C90| main.cpp|311|warning: this decimal constant is unsigned only in ISO C90| main.cpp|312|warning: this decimal constant is unsigned only in ISO C90| main.cpp|314|warning: this decimal constant is unsigned only in ISO C90| main.cpp||In function `int main()':| main.cpp|349|error: `MD5Init' cannot be used as a function| main.cpp|350|error: invalid conversion from `char*' to `unsigned char*'| main.cpp|350|error: initializing argument 2 of `void MD5Update(MD5_CTX*, unsigned char*, unsigned int)'| main.cpp|94|warning: 'void Transform()' declared `static' but never defined| main.cpp|225|warning: 'void Transform(UINT4*, UINT4*)' defined but not used| ||=== Build finished: 11 errors, 46 warnings ===|Rausgeschmissen hab ich
static void MDString (inString) char *inString; { MD5_CTX mdContext; unsigned int len = (unsigned int)strlen (inString); MD5Init (&mdContext); MD5Update (&mdContext, inString, len); MD5Final (&mdContext); }Mit funktionierts auch nicht

gruß
B
-
MD5String muss auf jeden fall raus. ändere den kopf von MD5Init von...
void MD5Init (mdContext) MD5_CTX *mdContext;in das...
void MD5Init (MD5_CTX *mdContext)^^schon müssten ein paar fehlerchen weg sein.

-
hi ;fricky,
danke für deine mühe,
nur leider folgt direkt der nächste fehler

main.cpp||In function `void MD5Update(MD5_CTX*, unsigned char*, unsigned int)':| main.cpp|94|error: too many arguments to function `void Transform()'| main.cpp|177|error: at this point in file| main.cpp||In function `void MD5Final(MD5_CTX*)':| main.cpp|94|error: too many arguments to function `void Transform()'| main.cpp|207|error: at this point in file| main.cpp||In function `void Transform(UINT4*, UINT4*)':| main.cpp||In function `int main()':| main.cpp|349|error: invalid conversion from `char*' to `unsigned char*'| main.cpp|349|error: initializing argument 2 of `void MD5Update(MD5_CTX*, unsigned char*, unsigned int)'| main.cpp|94|warning: 'void Transform()' declared `static' but never defined| main.cpp|224|warning: 'void Transform(UINT4*, UINT4*)' defined but not used| ||=== Build finished: 6 errors, 46 warnings ===|gruss
B
-
kein problem, weiter geht's. such die zeilen:
/* forward declaration */ void Transform ();und ändere sie in:
/* forward declaration */ void Transform (UINT4 *buf, UINT4 *in);
-
Du bist n feiner kerl,
danke das du dir so viel mühe gibst.
also ich hab jetzt
static void Transform ();in
static void Transform (UINT4 *buf, UINT4 *in);geändert.
jetzt kommt folgender Fehler:

main.cpp||In function `void Transform(UINT4*, UINT4*)':| main.cpp||In function `int main()':| main.cpp|349|error: invalid conversion from `char*' to `unsigned char*'| main.cpp|349|error: initializing argument 2 of `void MD5Update(MD5_CTX*, unsigned char*, unsigned int)'| ||=== Build finished: 2 errors, 44 warnings ===|Fehler verweist auf
MD5Update (&ctx, in, (unsigned int)strlen(in));Gruss
B
-
BigL schrieb:
Du bist n feiner kerl,
ja, das bin ich wirklich. *fg*
nun, dann gehen wir mal in die 'main'-funktion und machen aus der zeile:MD5Update (&ctx, in, (unsigned int)strlen(in));das...
MD5Update (&ctx, (unsigned char*)in, (unsigned int)strlen(in));
-
ahaa jaaa!
endlich nach einer million versuche!
ES FUNKTIONIERT!
DANKE ;fricky!!!
wieso das aber auch immer so kompliziert sein muss

hätte ich mit VC++ da keine probleme gehabt?
gruss
B
PS: an welche org soll ich das geld nun schicken?

-
BigL schrieb:
hätte ich mit VC++ da keine probleme gehabt?
doch, auch. das ++ suckt rum, ohne hätte es gleich beim ersten oder zweiten versuch geklappt.
BigL schrieb:
PS: an welche org soll ich das geld nun schicken?
irgendwas humanitäres o.ä, amnesty international, kinderhilfswerk, greenpeace oder so, such dir was aus. und wehe dir, die kohle geht bei denen nicht ein. ich rufe da an *fg*

-
ja danke wirklich.
ich werd das machen, im ernst.
ich sag dir dann bescheid wohin es ging

PS: kannst du mir noch schnell sagen wie ich den md5hash in ne variable packen kann?
(prinzipiell wollte ich das ja damit ich md5 hash in meiner applikation vergleichen kann)
gruss
B
-
BigL schrieb:
PS: kannst du mir noch schnell sagen wie ich den md5hash in ne variable packen kann?
das ergebnis ist in MD5_CTX.digest[], 16 unsigned char's (siehste z.b. an der ausgabe in 'main'). kannst es z.b. mit 'memcpy' o,ä. irgendwo hinkopieren. ansonsten arbeite mal ein C-tutorial durch, damit du überhaupt weisst, was du da machst.

-
hehe
ja ich weiss schon was ich da mach
sagen wir so ich kann die sprache besser lesen als schreiben

sowas hab ich noch nie gemacht

danke für die anhaltspunkte.
ich werds sicher rauskriegen.
das kann ja jetzt wohl nichtmehr sooo schwer sein.
danke nochmal vielmals für deine hilfe
gruss
B