Delphi para C#

.NET

30/09/2009

Galera,

Gostaria de exportar esta funcao para o C.

Atualmente, esta escrita em delphi.

Alguem pode me ajudar?

[b:54519e23d2]Abracos[/b:54519e23d2]

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;



Tremonti

Tremonti

Curtidas 0

Respostas

Rike

Rike

30/09/2009

Ola amigo...bom se voce tiver a source desse programa criado em Delphi..voce podera utilizar o ´[b:76adc3b2f9]TurnSharp[/b:76adc3b2f9]´
ele é um software que contem 2 versões...
1º Delphi > C
2º VB > C

Bom esse software ele é pago...mas tem sua versão trial...
que se encontra aqui: https://www.turnsharp.com/try-it.aspx
é só preencher os campos...
Só da para instalar 1º versão por vez no computador...
No seu caso seria a Delphi>C, lembrando que voce tem que ter a source do programa , para que o turnsharp possa converter ela para c :}

Espero ter te ajudado


GOSTEI 0
POSTAR