CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Guest

    Delphi to VB Conversion Help

    I need these two functions converted to VB...
    Can someone help, please???

    function Decrypt(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(S[i]) + Key) * C1 + C2;
    end;
    end;


    function Encrypt(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;




  2. #2
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Delphi to VB Conversion Help

    I'm not sure if this is exactly word for word, but I hope you will get the basic of encrypting/decrypting:

    private Function Decrypt(byval SEnc as string)
    for I = 1 to len(SEnc)
    Str = mid(SEnc, I, 1)
    mid(SEnc, I, 1) = Chr(Asc(Str) - 1)
    next
    Decrypt = SEnc
    End Function




    private Function Encrypt(byval S as string)
    for I = 1 to len(S)
    Str= mid(S, I, 1)
    mid(S, I, 1) = Chr(Asc(Str) + 1)
    next
    Encrypt = S
    End Function







  3. #3
    Guest

    Re: Delphi to VB Conversion Help

    I'm afraid that would not do what I'm looking for.
    I need to be able to use the same table in both
    applications so the strings MUST be identical when
    encrypted by EITHER the Delphi program or the VB
    program.

    Thanks for trying...


  4. #4
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Delphi to VB Conversion Help

    You can make a textbox and use Encrypt and Decrypt functions to get the string from that that textbox....


  5. #5
    Guest

    Re: Delphi to VB Conversion Help

    What the hell are you talking about? I already have the text boxes and I want to encrypt/decrypt the values in those text boxes as well as values in the
    fields of a table.

    I just want the algorithm I posted converted to VB so I can use the SAME DATA
    in BOTH APPLICATIONS!!!!!



  6. #6
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Delphi to VB Conversion Help

    I DOnt know Delphi.. and i use to know (?) Pascal!. So what is shr : "Shift right" is what i guessed. But then shift right 8 times with or w/o carry (meaning loop back or not)? What are C1 and C2?

    RK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured