Thread View: borland.public.cppbuilder.internet.socket
6 messages
6 total messages
Started by Lapo Guidi
Tue, 27 Jun 2006 11:57
TIdHashMessageDigest5 and BCB 6
Author: Lapo Guidi
Date: Tue, 27 Jun 2006 11:57
Date: Tue, 27 Jun 2006 11:57
19 lines
1322 bytes
1322 bytes
Hi all,
I got problems getting the MD5 value of a simple String with Borland C++
Builder 6 and Indy v9, can somebody help me?
I wrote:
T4x4LongWordRecord Hash;
AnsiString Hex;
TIdHashMessageDigest5 *MD5=new TIdHashMessageDigest5();
Hash=MD5->HashValue("testmessage");
Hex=MD5->AsHex(NULL, Hash);
delete MD5;
I received an error: E2277 Lvalue required on the
"Hash=MD5->HashValue("testmessage"); row
Thanks!
Lapo
Re: TIdHashMessageDigest5 and BCB 6
Author: Andrue Cope [TeamB]
Date: Tue, 27 Jun 2006 12:36
Date: Tue, 27 Jun 2006 12:36
32 lines
1910 bytes
1910 bytes
Lapo Guidi wrote:
That error message means that the compiler was expecting to assign a
value into something and the something you gave it isn't something that
can be assigned to.
> T4x4LongWordRecord Hash;
> AnsiString Hex;
> TIdHashMessageDigest5 *MD5=new TIdHashMessageDigest5();
> Hash=MD5->HashValue("testmessage");
I haven't used Indy but looking at the online docs it appears that
HashValue() returns an array of 32 bit values. That means you're trying
to assign to an array which is not allowed in C++ eg;
typedef DWORD array[ 4 ] Tbaddy;
Tbaddy someFunction();
Tbaddy array=someFunction();
// An array cannot be assigned to hence is not a valid Left Hand Side
// of an expression
Then again why call it 'T4x4LongWord/Record/' if it is an array?
Presumably there is some C++ specific workaround implemented - what
does the C++ specific documentation say for HashValue() and
T4x4LongWord?
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Re: TIdHashMessageDigest5 and BCB 6
Author: Lapo Guidi
Date: Tue, 27 Jun 2006 13:05
Date: Tue, 27 Jun 2006 13:05
13 lines
1361 bytes
1361 bytes
> Presumably there is some C++ specific workaround implemented - what > does the C++ specific documentation say for HashValue() and > T4x4LongWord? Thanks for the fast reply. Unfortunately I'm not able to find C++ specific documentation. I found many people asking for a C++ example, but I can see just Delphi examples. Anyway, I'll try to find another MD5 library. Thank you very much Lapo
Re: TIdHashMessageDigest5 and BCB 6
Author: Andrue Cope [TeamB]
Date: Tue, 27 Jun 2006 13:53
Date: Tue, 27 Jun 2006 13:53
14 lines
1419 bytes
1419 bytes
Lapo Guidi wrote: > Thanks for the fast reply. > Unfortunately I'm not able to find C++ specific documentation. > I found many people asking for a C++ example, but I can see just > Delphi examples. Anyway, I'll try to find another MD5 library. Well you can use Goto declaration to find out how T4x4LongWordRecord is declared. That might give an indication of how they get around it. -- Andrue Cope [TeamB] [Bicester, Uk] http://info.borland.com/newsgroups/guide.html
Re: TIdHashMessageDigest5 and BCB 6
Author: Lapo Guidi
Date: Tue, 27 Jun 2006 16:33
Date: Tue, 27 Jun 2006 16:33
5 lines
1217 bytes
1217 bytes
> Well you can use Goto declaration to find out how T4x4LongWordRecord is > declared. That might give an indication of how they get around it. This is the T4x4LongWordRecord declaration: T4x4LongWordRecord = array [0..3] of LongWord;
Re: TIdHashMessageDigest5 and BCB 6
Author: Remy Lebeau (TeamB)
Date: Tue, 27 Jun 2006 17:35
Date: Tue, 27 Jun 2006 17:35
68 lines
2692 bytes
2692 bytes
"Lapo Guidi" <lapoguidi@inwind.it> wrote in message
news:44a15dd2@newsgroups.borland.com...
> This is the T4x4LongWordRecord declaration:
> T4x4LongWordRecord = array [0..3] of LongWord;
In C++, it comes out as the following:
typedef unsigned T4x4LongWordRecord[4];
The declaration for T4x4x4LongWordRecord in C++ comes out as follows:
typedef unsigned T4x4x4LongWordRecord[4][4];
Functions in C++ can't return array values. However, if you look at the
declaration for HashValue() itself in C++, it does not return an array at
all:
unsigned __fastcall HashValue(const AnsiString ASrc);
What you can try doing is to add a Delphi .pas file to your C++ project, and
have that file call HashValue() and return the array in a manner that C++
can handle. For example (untested):
--- HashValueUnit.pas ---
unit HashValueUnit;
uses
IdHashMessageDigest5;
interface
procedure MD5HashValue(MD5: TIdHashMessageDigest5; const S: String; var
Hash: PLongWord);
implementation
procedure MD5HashValue(MD5: TIdHashMessageDigest5; const S: String;
Hash: PLongWord);
var
Tmp: T4x4LongWordRecord;
begin
Tmp := MD5.HashValue(S);
Move(Tmp[0], Hash, SizeOf(LongWord)*4);
end;
end.
--- MyForm.cpp ---
#include "HashValueUnit.hpp"
{
//...
TIdHashMessageDigest5 *MD5 = new TIdHashMessageDigest5;
T4x4LongWordRecord Hash;
MD5HashValue(MD5, "testmessage", Hash);
AnsiString Hex = MD5->AsHex(__classid(TIdHashMessageDigest5), Hash);
//...
}
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads