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 := char(byte(S) xor (Key shr 8));
Key := (byte(Result) + 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) 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) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st) 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,

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

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) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st) 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,

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

Is the result even remotely similar?

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.

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

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;
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;

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.