Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.pascal.delphi.misc > #328 > unrolled thread
| Started by | bok <bok.globule@gmail.com> |
|---|---|
| First post | 2012-06-15 21:49 -0700 |
| Last post | 2012-06-26 23:06 +0200 |
| Articles | 15 — 7 participants |
Back to article view | Back to comp.lang.pascal.delphi.misc
Works in D6 not in XE2... any help is appreciated bok <bok.globule@gmail.com> - 2012-06-15 21:49 -0700
Re: Works in D6 not in XE2... any help is appreciated "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-16 07:30 +0200
Re: Works in D6 not in XE2... any help is appreciated bok <bok.globule@gmail.com> - 2012-06-16 00:09 -0700
Re: Works in D6 not in XE2... any help is appreciated "S.G" <S.G@none.special.ch> - 2012-06-16 12:01 +0300
Re: Works in D6 not in XE2... any help is appreciated JJ <jaejunks_at@_googlemail_dot._com> - 2012-06-16 15:39 +0000
Re: Works in D6 not in XE2... any help is appreciated "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-16 17:58 +0200
Re: Works in D6 not in XE2... any help is appreciated Marco van de Voort <marcov@toad.stack.nl> - 2012-06-16 18:37 +0000
Re: Works in D6 not in XE2... any help is appreciated "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-17 05:37 +0200
Re: Works in D6 not in XE2... any help is appreciated "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-16 17:58 +0200
Re: Works in D6 not in XE2... any help is appreciated "Ph. B." <philippe_NO_SPAM_.boucault@voila.fr> - 2012-06-16 19:53 +0200
Re: Works in D6 not in XE2... any help is appreciated "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-17 05:38 +0200
Re: Works in D6 not in XE2... any help is appreciated JJ <jaejunks_at@_googlemail_dot._com> - 2012-06-17 04:48 +0000
Re: Works in D6 not in XE2... any help is appreciated bok <bok.globule@gmail.com> - 2012-06-18 02:48 -0700
Re: Works in D6 not in XE2... any help is appreciated "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2012-06-18 13:52 +0200
Re: Works in D6 not in XE2... any help is appreciated "Maarten Wiltink" <maarten@kittensandcats.net> - 2012-06-26 23:06 +0200
| From | bok <bok.globule@gmail.com> |
|---|---|
| Date | 2012-06-15 21:49 -0700 |
| Subject | Works in D6 not in XE2... any help is appreciated |
| Message-ID | <6be86aa5-a63a-4c4e-9c7a-eee5bded75c7@googlegroups.com> |
The following works fine in D6+Win7 but I get "Invalid buffer size for decryption" error under XE2+Win7 during decrypion(button2Click). A mozillla liscensed unit from 2001 that does the actual AES operations is raising that error, but I hesitate to include that unit here as it is hundreds of lines long,
but TAESKey128 = array [0..15] of byte is in the TYPE statement there.
I'm guessing that the problem is either a change in the "Size" "fillchar" pointer "^" or "move" operations between D6 and XE2 or the fact that I'm running a 64bit OS (Windows was 16 bit in 2001)
=======================================================================
function StringToHex(S: string): string; // Convert all characters to hex
var i: integer;
begin
Result := '';
for i := 1 to Length( S ) do Result := Result + IntToHex( Ord( S[i] ), 2 );
end;
function HexToString(S: string): string;
var i: integer;
begin
Result := '';
for i := 1 to Length( S ) do
if ((i mod 2) = 1) then
Result := Result + Chr( StrToInt( '0x' + Copy( S, i, 2 )));
end;
procedure TForm1.Button1Click(Sender: TObject);// Encryption
var
Source: TStringStream;
Dest: TStringStream;
Size: integer;
Key: TAESKey128;
begin
Source := TStringStream.Create( Memo1.Text );
Dest := TStringStream.Create( '' );
try
Size := Source.Size;
Dest.WriteBuffer( Size, SizeOf(Size) );
FillChar( Key, SizeOf(Key), 0 ); // Prepare key
Move( PChar(edit1.Text)^, Key, Min( SizeOf( Key ), Length( edit1.Text )));
EncryptAESStreamECB( Source, 0, Key, Dest );
Memo2.Text := StringToHex( Dest.DataString );
finally
Source.Free;
Dest.Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Source: TStringStream;
Dest: TStringStream;
Size: integer;
Key: TAESKey128;
begin
Source := TStringStream.Create( HexToString( Memo2.Text ));
Dest := TStringStream.Create( '' );
try
Size := Source.Size;
Source.ReadBuffer(Size, SizeOf(Size));
FillChar(Key, SizeOf(Key), 0);
Move(PChar(edit1.Text)^, Key, Min(SizeOf(Key), Length(edit1.Text)));
DecryptAESStreamECB(Source, Source.Size - Source.Position, Key,Dest);
Memo1.Text := Dest.DataString;
finally
Source.Free;
Dest.Free;
end;
end;
Thanks for your help
DBM
[toc] | [next] | [standalone]
| From | "Maarten Wiltink" <maarten@kittensandcats.net> |
|---|---|
| Date | 2012-06-16 07:30 +0200 |
| Message-ID | <4fdc1a05$0$6975$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #328 |
"bok" <bok.globule@gmail.com> wrote in message news:6be86aa5-a63a-4c4e-9c7a-eee5bded75c7@googlegroups.com... > The following works fine in D6+Win7 but I get "Invalid buffer size > for decryption" error under XE2+Win7 during decrypion(button2Click). [...] > I'm guessing that the problem is either a change in the "Size" > "fillchar" pointer "^" or "move" operations between D6 and XE2 or > the fact that I'm running a 64bit OS (Windows was 16 bit in 2001) Windows was 32 bits although it had a 16-bits Windows subsystem. Delphi was and is 32 bits but I hear a 64 bits version is coming soon. The difference is more likely in the string types. They became Unicode between D6 and XE2, and characters went from one to two bytes. Groetjes, Maarten Wiltink
[toc] | [prev] | [next] | [standalone]
| From | bok <bok.globule@gmail.com> |
|---|---|
| Date | 2012-06-16 00:09 -0700 |
| Message-ID | <09c24c11-213e-43cb-a52a-96aa8dc9a518@googlegroups.com> |
| In reply to | #330 |
> The difference is more likely in the string types. They became Unicode > between D6 and XE2, and characters went from one to two bytes. > > Groetjes, > Maarten Wiltink Maarten, Thank you for your reply. I am not a professional and program only as a hobby. Can you tell me how to fix this code so that it will work (ascii vs. unicode)under XE2? Thank You Bok
[toc] | [prev] | [next] | [standalone]
| From | "S.G" <S.G@none.special.ch> |
|---|---|
| Date | 2012-06-16 12:01 +0300 |
| Message-ID | <jrhi17$9g9$1@speranza.aioe.org> |
| In reply to | #331 |
bok wrote: > Can you tell me how to fix this code so that it will > work (ascii vs. unicode)under XE2? > I tried to install XE2 evaluation package about one year ago, but never got it to work. The first Delphi version, ever, that refused to compile even a one Button test application. So my XE2 expertise and even upgrading to All Unicode is quite thin. Yet you could try to replace all you String types to AnsiString types, and your problem at this specific place might go away. http://edn.embarcadero.com/article/38437 "The default string in Delphi 2009 is the new UnicodeString type. By default, the UnicodeString type will have an affinity for UTF-16, the same encoding used by Windows. This is a change from previous versions which had AnsiString as the default type." S.G.
[toc] | [prev] | [next] | [standalone]
| From | JJ <jaejunks_at@_googlemail_dot._com> |
|---|---|
| Date | 2012-06-16 15:39 +0000 |
| Message-ID | <XnsA074E68EE45C5jaejunksgooglemailco@0.0.0.54> |
| In reply to | #331 |
bok <bok.globule@gmail.com> wrote in news:09c24c11-213e-43cb-a52a-96aa8dc9a518@googlegroups.com: > Maarten, > > Thank you for your reply. I am not a professional and program only as > a hobby. Can you tell me how to fix this code so that it will work > (ascii vs. unicode)under XE2? > > Thank You > Bok Change all refererence of "string" variable type to "ansistring" in all of your source codes including third-party ones that are not Delphi 2005+ aware.
[toc] | [prev] | [next] | [standalone]
| From | "Rudy Velthuis" <newsgroups@rvelthuis.de> |
|---|---|
| Date | 2012-06-16 17:58 +0200 |
| Message-ID | <xn0hzeyx59j5xb00k@news.1und1.de> |
| In reply to | #334 |
JJ wrote: > bok <bok.globule@gmail.com> wrote in > news:09c24c11-213e-43cb-a52a-96aa8dc9a518@googlegroups.com: > > > Maarten, > > > > Thank you for your reply. I am not a professional and program only > > as a hobby. Can you tell me how to fix this code so that it will > > work (ascii vs. unicode)under XE2? > > > > Thank You > > Bok > > Change all refererence of "string" variable type to "ansistring" in > all of your source codes No, don't. On the contrary. Simple leave things as they are, recompile and handle and warnings or errors you may get. Soon it will compile and be fully Unicode. -- Rudy Velthuis "It's clearly a budget. It's got a lot of numbers in it." -- George W. Bush
[toc] | [prev] | [next] | [standalone]
| From | Marco van de Voort <marcov@toad.stack.nl> |
|---|---|
| Date | 2012-06-16 18:37 +0000 |
| Message-ID | <slrnjtpkjg.2t32.marcov@toad.stack.nl> |
| In reply to | #336 |
On 2012-06-16, Rudy Velthuis <newsgroups@rvelthuis.de> wrote: >> > Thank You >> > Bok >> >> Change all refererence of "string" variable type to "ansistring" in >> all of your source codes > > No, don't. On the contrary. Simple leave things as they are, recompile > and handle and warnings or errors you may get. Soon it will compile and > be fully Unicode. Strange. One of the glaring mistakes is a move(..,..,length(s)); that is never going to fix itself.
[toc] | [prev] | [next] | [standalone]
| From | "Rudy Velthuis" <newsgroups@rvelthuis.de> |
|---|---|
| Date | 2012-06-17 05:37 +0200 |
| Message-ID | <xn0hzfu0myj5od01e@news.1und1.de> |
| In reply to | #338 |
Marco van de Voort wrote: > On 2012-06-16, Rudy Velthuis <newsgroups@rvelthuis.de> wrote: > >> > Thank You > >> > Bok > >> > >> Change all refererence of "string" variable type to "ansistring" in > >> all of your source codes > > > > No, don't. On the contrary. Simple leave things as they are, > > recompile and handle and warnings or errors you may get. Soon it > > will compile and be fully Unicode. > > Strange. One of the glaring mistakes is a move(..,..,length(s)); that > is never going to fix itself. Correct. I assumed that people don't do this. Of course any low level stuff like Move, FillChar, GetMem, FreeMem, etc. must be looked at with suspicion. Just like any "clever" code that uses strings for non-text binary data storage. -- Rudy Velthuis "You have a cough? Go home tonight, eat a whole box of Ex-Lax -- tomorrow you'll be afraid to cough." -- Pearl Williams.
[toc] | [prev] | [next] | [standalone]
| From | "Rudy Velthuis" <newsgroups@rvelthuis.de> |
|---|---|
| Date | 2012-06-16 17:58 +0200 |
| Message-ID | <xn0hzeyx19j06q00j@news.1und1.de> |
| In reply to | #330 |
Maarten Wiltink wrote: > Windows was 32 bits although it had a 16-bits Windows subsystem. > Delphi was and is 32 bits but I hear a 64 bits version is coming soon. Have you been sleeping, the last few months? Delphi XE2 can compile natively for Win32, Win64 and OS X targets, these days. -- Rudy Velthuis "For animals, the entire universe has been neatly divided into things to (a) mate with, (b) eat, (c) run away from, and (d) rocks." -- Terry Pratchett (Equal Rites)
[toc] | [prev] | [next] | [standalone]
| From | "Ph. B." <philippe_NO_SPAM_.boucault@voila.fr> |
|---|---|
| Date | 2012-06-16 19:53 +0200 |
| Message-ID | <4fdcc848$0$1992$426a74cc@news.free.fr> |
| In reply to | #335 |
Rudy Velthuis a écrit : > Maarten Wiltink wrote: > >> Windows was 32 bits although it had a 16-bits Windows subsystem. >> Delphi was and is 32 bits but I hear a 64 bits version is coming soon. > > Have you been sleeping, the last few months? Delphi XE2 can compile > natively for Win32, Win64 and OS X targets, these days. May be he was speaking about IDE which is until now only 32 bits... ;-) -- Philippe.
[toc] | [prev] | [next] | [standalone]
| From | "Rudy Velthuis" <newsgroups@rvelthuis.de> |
|---|---|
| Date | 2012-06-17 05:38 +0200 |
| Message-ID | <xn0hzfu1lykkcl01f@news.1und1.de> |
| In reply to | #337 |
Ph. B. wrote: > Rudy Velthuis a écrit : > > Maarten Wiltink wrote: > > > > > Windows was 32 bits although it had a 16-bits Windows subsystem. > > > Delphi was and is 32 bits but I hear a 64 bits version is coming > > > soon. > > > > Have you been sleeping, the last few months? Delphi XE2 can compile > > natively for Win32, Win64 and OS X targets, these days. > > May be he was speaking about IDE which is until now only 32 bits... > ;-) Perhaps, but since this thread was about code posted, and not about the IDE, I doubt it a bit. -- Rudy Velthuis "Go away...I'm alright." -- H.G.Wells, dying words
[toc] | [prev] | [next] | [standalone]
| From | JJ <jaejunks_at@_googlemail_dot._com> |
|---|---|
| Date | 2012-06-17 04:48 +0000 |
| Message-ID | <XnsA07578431D6B6jaejunksgooglemailco@0.0.0.54> |
| In reply to | #335 |
"Rudy Velthuis" <newsgroups@rvelthuis.de> wrote in news:xn0hzeyx19j06q00j@news.1und1.de: > Have you been sleeping, the last few months? Delphi XE2 can compile > natively for Win32, Win64 and OS X targets, these days. He's busy at work, apparently. That's why he's still using Delphi 6 or at least still keep it.
[toc] | [prev] | [next] | [standalone]
| From | bok <bok.globule@gmail.com> |
|---|---|
| Date | 2012-06-18 02:48 -0700 |
| Message-ID | <879dc076-1dd8-4f07-9cb1-671adfd86068@googlegroups.com> |
| In reply to | #343 |
> > Have you been sleeping, the last few months? Delphi XE2 can compile > > natively for Win32, Win64 and OS X targets, these days. Not the "starter" edition >>If converting to Unicode... >>If a "length(s)" is being used as a byte count rather than a character >>count, for a move statement, it should be changed to: >>move(..., ..., length(s) * sizeof(char)) Got it. Thank you JJ for your help. I am 'almost' a senior citizen and except for a Fortran class 30 years ago I'm trying to learn this stuff on my own.
[toc] | [prev] | [next] | [standalone]
| From | "Rudy Velthuis" <newsgroups@rvelthuis.de> |
|---|---|
| Date | 2012-06-18 13:52 +0200 |
| Message-ID | <xn0hzhll82vn54b000@news.1und1.de> |
| In reply to | #344 |
bok wrote: > > > Have you been sleeping, the last few months? Delphi XE2 can > > > compile natively for Win32, Win64 and OS X targets, these days. > > Not the "starter" edition I don't know. I do know that the other editions do. -- Rudy Velthuis "When his life was ruined, his family killed, his farm destroyed, Job knelt down on the ground and yelled up to the heavens, 'Why god? Why me?' and the thundering voice of God answered, 'There's just something about you that pisses me off.'" -- Stephen King.
[toc] | [prev] | [next] | [standalone]
| From | "Maarten Wiltink" <maarten@kittensandcats.net> |
|---|---|
| Date | 2012-06-26 23:06 +0200 |
| Message-ID | <4fea2447$0$6955$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #343 |
"JJ" <jaejunks_at@_googlemail_dot._com> wrote in message news:XnsA07578431D6B6jaejunksgooglemailco@0.0.0.54... > "Rudy Velthuis" <newsgroups@rvelthuis.de> wrote in > news:xn0hzeyx19j06q00j@news.1und1.de: >> Have you been sleeping, the last few months? ... Short answer: yes. I don't have the time anymore to keep up with the Borland, no CodeGear, no Embarcadero, newsgroups. Those who know the details also know why I suffer this gladly. > He's busy at work, apparently. That's why he's still using Delphi 6 ... Delphi 6? I wish. One of these days I'm going to have to sabotage my ocmputer and claim that it can only be fixed by buying a new, _recent_, Delphi. At which point they may listen throw away the legacy application instead. Groetjes, Maarten Wiltink
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.pascal.delphi.misc
csiph-web