CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    1

    Unhappy Delphi to CSharp

    Hello,

    I wold like to export this code( Delphi ) to C#

    Can Help me?

    Código:
    function CryptAlgorithm(cString: String): String;
    var
    nStringLen, nCharCount: Integer;
    nInterim, nChar: Byte;
    cChar: Char;
    begin
    nStringLen := length( cString );

    if nStringLen = 0 then begin
    nKey := 0;
    nSalt := 0;
    end
    else begin
    for nCharCount := 0 to nStringLen - 1 do begin
    cChar := cString[ nCharCount+1 ];

    { only encipher printable characters }
    if (( cChar >= ' ' ) and ( cChar <= '~' )) then begin
    nkey := ( nkey and $1FFFFFFF ) xor (( nkey shr 29 ) and $00000031 );
    nChar := Byte( cChar );
    nInterim := Mod95(( nKey div 95 ) - ( nChar - 32 )) + 32;
    nSalt := nSalt + 1;

    if ( nSalt >= 20857 ) then begin
    nSalt := 0;
    end;

    nKey := nKey + nKey + ( nInterim xor nChar ) + nSalt;

    cString[ nCharCount+1 ] := Char( nInterim );
    end;
    end;
    end;
    Result := cString;
    end;


    function Mod95( nVal : Integer ): Integer;
    begin
    Result := nVal;

    while ( Result >= 9500 ) do begin
    Result := Result - 9500;
    end;

    while ( Result >= 950 ) do begin
    Result := Result - 950;
    end;

    while ( Result >= 95 ) do begin
    Result := Result - 95;
    end;

    while ( Result < 0 ) do begin
    Result := Result + 95;
    end;
    end;

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Delphi to CSharp

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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