Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi MD5 Hash (https://www.delphipraxis.net/97631-md5-hash.html)

dominikkv 13. Aug 2007 22:42


MD5 Hash
 
hi

für ein HTTP.Get brauche ich einen MD5-Hash.
In der Dokumentation der Webseite steht folgendes:
Zitat:

The algorithm for generating this token is as follows:
token := md5(md5(password) + timestamp)

The md5() function takes a string and returns the 32-byte ASCII hexadecimal representation of the MD5 hash, using lower case characters for the hex values. The '+' operator represents concatenation of the two strings.
den Timestamp hab ich, jetzt fehlt nur noch die richtige Hash-Funktion.
Ich hab mir mal die DEC angeschaut und folgendes versucht:
Delphi-Quellcode:
THash_MD5.CalcBinary(THash_MD5.CalcBinary(Passwort) + TimeStamp));
Leider führt das nicht zum Erfolg...
Hat jemand eine Idee?

mfg.Dominik

Andreas L. 13. Aug 2007 23:05

Re: MD5 Hash
 
http://www.google.com/codesearch?hl=...s_f=MD5.pas#a0

mirage228 13. Aug 2007 23:07

Re: MD5 Hash
 
Hey,

Wieso nimmst du nicht die Funktion CalcString von THash_MD5 ?

mfG
mirage228

Luckie 13. Aug 2007 23:32

Re: MD5 Hash
 
Zitat:

Zitat von dominikkv
Leider führt das nicht zum Erfolg...
Hat jemand eine Idee?

Ja, sag uns, was du unter "führt nicht um Erfolg" verstehst.

dominikkv 14. Aug 2007 06:01

Re: MD5 Hash
 
Zitat:

Zitat von Andreas L.
http://www.google.com/codesearch?hl=de&q=+md5.pas+show:cSgfkSoWP30:LkICx ivafk0:CAtxQJQb3aw&sa=N&cd=1&ct=rc&cs_p=http://www.daremon.gr/flickr/Releases/dFlickr-0.9.3b.zip&cs_f=MD5.pas#a0

Danke, werde ich mir nacher mal anschauen


Zitat:

Zitat von mirage228
Hey,
Wieso nimmst du nicht die Funktion CalcString von THash_MD5 ?

Ähh... weil es die nicht gibt?
Also bei mir aufjedenfall...


Zitat:

Zitat von Luckie
Zitat:

Zitat von dominikkv
Leider führt das nicht zum Erfolg...
Hat jemand eine Idee?

Ja, sag uns, was du unter "führt nicht um Erfolg" verstehst.

Das ist ein Teil von einem Handshake. (klick)
bisher bin ich so weit:
Delphi-Quellcode:
  TimeStamp := IntToStr(TimeStampHumanToUnix(Now, True));

  Memo1.Text := HTTP1.Get('http://post.audioscrobbler.com/?hs=true&p=1.2'+
        '&c=tst'+
        '&v=1.0'+
        '&u=mYname'+
        '&t='+TimeStamp+
        '&a='+THash_MD5.CalcBinary(THash_MD5.CalcBinary('mYpassword') + TimeStamp));
end;
und als Antwort kommt: BADAUTH
Und Benutzername und PW sind richtig (hab ich jetzt natürlich hier rausgenommen).

Klaus01 14. Aug 2007 07:29

Re: MD5 Hash
 
Guten Morgen,

in Deinem ersten Beitrag steht:

Zitat:

Zitat von dominikkv
The md5() function takes a string and returns the 32-byte ASCII hexadecimal representation of the MD5 hash, using lower case characters for the hex values. The '+' operator represents concatenation of the two strings.

Bist Du sicher, dass THash_md5.CalcBinary den md5 Hashwert als Stringzurückgibt?
Und bist Du sicher das die Zeichen die zurückgegeben werden auch alles kleine Zeichen sind?

Grüße
Klaus

negaH 14. Aug 2007 11:21

Re: MD5 Hash
 
Delphi-Quellcode:
THash_MD5.CalcBinary(THash_MD5.CalcBinary('mYpassword') + TimeStamp, TFormat_HEXL)
Steht doch in der Anleitung "lowercase formatted HEX string".

.CalcBinary(Daten, Format) erwartet bei Formt eine der TFormat_XYZ Klassen um den binären Digest in ein anderes Textformat zu konvertieren.

Gruß Hagen

dominikkv 14. Aug 2007 17:46

Re: MD5 Hash
 
hmm... kaum macht mans richtig, schon klappts...
in diesem Fall:
Delphi-Quellcode:
THash_MD5.CalcBinary(THash_MD5.CalcBinary('mYpw', TFormat_HEXL) + TimeStamp, TFormat_HEXL)
danke an euch alle :zwinker:

negaH 14. Aug 2007 18:23

Re: MD5 Hash
 
Die ziehen einen HEX-Formatierten Hash über das Passwort, hängen hintendran einen lesbar formatierten Timestamp und ziehen über das alles nochmal einen Hash. Das halte ich für hm nicht so gut.

Gruß Hagen


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:29 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz