convert delphi to vb 6.0

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Nov 2008
Posts: 18
Reputation: poilkjmnb is an unknown quantity at this point 
Solved Threads: 0
poilkjmnb poilkjmnb is offline Offline
Newbie Poster

convert delphi to vb 6.0

 
0
  #1
Nov 4th, 2008
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,
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: convert delphi to vb 6.0

 
0
  #2
Nov 4th, 2008
What have you got so far? We dont tend to do your work for you!
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 18
Reputation: poilkjmnb is an unknown quantity at this point 
Solved Threads: 0
poilkjmnb poilkjmnb is offline Offline
Newbie Poster

Re: convert delphi to vb 6.0

 
0
  #3
Nov 4th, 2008
Originally Posted by LizR View Post
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,
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: convert delphi to vb 6.0

 
0
  #4
Nov 4th, 2008
Dont re-invent the wheel. Download the function done by someone else

http://www.vbforums.com/showthread.php?t=379072
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 18
Reputation: poilkjmnb is an unknown quantity at this point 
Solved Threads: 0
poilkjmnb poilkjmnb is offline Offline
Newbie Poster

Re: convert delphi to vb 6.0

 
0
  #5
Nov 4th, 2008
Originally Posted by LizR View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: convert delphi to vb 6.0

 
0
  #6
Nov 4th, 2008
hmm, it should as the encode64 function has a standard expectation.

Is the result even remotely similar?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 18
Reputation: poilkjmnb is an unknown quantity at this point 
Solved Threads: 0
poilkjmnb poilkjmnb is offline Offline
Newbie Poster

Re: convert delphi to vb 6.0

 
0
  #7
Nov 4th, 2008
Originally Posted by LizR View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: convert delphi to vb 6.0

 
0
  #8
Nov 4th, 2008
and in vb 6? (something I dont have installed as I wouldnt use it by choice)
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC