954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

convert delphi to vb 6.0

Hello Friends,

Any body help me to convert the code from Delphi to vb 6.0

const
C1 = 43941;
C2 = 16302;

function BorlandEncrypt(const S: String; Key: Word): String;
var
I: byte;
begin
SetLength(Result,Length(S));
for I := 1 to Length(S) do begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
end;


function Encrypt(password : string) : string;
begin
{ ----old encrypt ----
result := '';
for i := 1 to length(password) do
result := result + char( (ord(password[i]) xor 43) + 11 ); }

// new encrypt
password := BorlandEncrypt(password,17732);
Result := '<' + Encode64(password) + '>';
//Result := '<' + Encode64(password) + '>';
end;

function Encode64(st : string) : string;
////////////////////////////////////////////////////////////////////////////////
// Base64 Encode a string (RFC 1521)
// Copyright © 2001 - Renier Crause
var
i,idx : integer;
begin
Result := '';
i := 1;
while i <= length(st) do
begin
// 1st char
idx := ord(st[i]) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st[i]) and $3 shl 4);
if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
Result := Result + Alphabet[idx+1];
// 3rd char
if i+1 <= length(st) then
begin
idx := (ord(st[i+1]) and $F shl 2);
if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// 4th char
if i+2 <= length(st) then
begin
idx := (ord(st[i+2]) and $3F);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// next source char
Inc(i,3);
end;
end;


Thanks,

poilkjmnb
Newbie Poster
18 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

What have you got so far? We dont tend to do your work for you!

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 
What have you got so far? We dont tend to do your work for you!

Hello Lizr,

i m not work in delphi but i need to convert it to vb 6.0 for my application. can u help me to convert this code

function Encode64(st : string) : string;
////////////////////////////////////////////////////////////////////////////////
// Base64 Encode a string (RFC 1521)
// Copyright © 2001 - Renier Crause
var
i,idx : integer;
begin
Result := '';
i := 1;
while i <= length(st) do
begin
// 1st char
idx := ord(st[i]) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st[i]) and $3 shl 4);
if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
Result := Result + Alphabet[idx+1];
// 3rd char
if i+1 <= length(st) then
begin
idx := (ord(st[i+1]) and $F shl 2);
if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// 4th char
if i+2 <= length(st) then
begin
idx := (ord(st[i+2]) and $3F);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// next source char
Inc(i,3);
end;
end;

Thanks,

poilkjmnb
Newbie Poster
18 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

Dont re-invent the wheel. Download the function done by someone else

http://www.vbforums.com/showthread.php?t=379072

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

Dont re-invent the wheel. Download the function done by someone else

http://www.vbforums.com/showthread.php?t=379072

Thanks LizR.

but this encode string doesn't match the string which is return by delphi code.

poilkjmnb
Newbie Poster
18 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

hmm, it should as the encode64 function has a standard expectation.

Is the result even remotely similar?

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

hmm, it should as the encode64 function has a standard expectation.

Is the result even remotely similar?

Hello LizR,

when i m enter "pramod" as encode string in delphi code then it return me "NasK3DkF" after encoding.

poilkjmnb
Newbie Poster
18 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

and in vb 6? (something I dont have installed as I wouldnt use it by choice)

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

Form1.Image2.Picture:=Form1.Image1.Picture;
latar:=255;
obyek:=0;
setlength(ki,w,h);
setlength(kio,w,h);
for y:= 0 to hi do
begin
PC :=formutama.image1.picture.bitmap.scanline[y];
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:=0 to wj do
begin
ki[x,y]:=PC[x];
kio[x,y]:=PH[x];
end;
end;

for x:= 1 to w-1 do
for y:= 1 to h-1 do
if(ki[x,y]=obyek) then
begin
kio[x-1,y]:=obyek;
kio[x+1,y]:=obyek;
kio[x,y-1]:=obyek;
kio[x,y+1]:=obyek;
end;

for y := 0 to hi do {tampil citra hasil}
begin
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:= 0 to wj do PH[x]:=kio[x,y];
end;
ki:=nil;kio:=nil;

arutya
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Form1.Image2.Picture:=Form1.Image1.Picture;
latar:=255;
obyek:=0;
setlength(ki,w,h);
setlength(kio,w,h);
for y:= 0 to hi do
begin
PC :=formutama.image1.picture.bitmap.scanline[y];
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:=0 to wj do
begin
ki[x,y]:=PC[x];
kio[x,y]:=PH[x];
end;
end;

for x:= 1 to w-1 do
for y:= 1 to h-1 do
if(ki[x,y]=obyek) then
begin
kio[x-1,y]:=obyek;
kio[x+1,y]:=obyek;
kio[x,y-1]:=obyek;
kio[x,y+1]:=obyek;
end;

for y := 0 to hi do {tampil citra hasil}
begin
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:= 0 to wj do PH[x]:=kio[x,y];
end;
ki:=nil;kio:=nil;

arutya
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

For converting Delphi to VB 6 you can download the complete information from Searching in Google.com regarding the conversion parameter.

CygnetInfo
Light Poster
32 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You