PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum Delphi para C# #375464

30/09/2009

0

Galera,

Gostaria de exportar esta funcao para o C.

Atualmente, esta escrita em delphi.

Alguem pode me ajudar?

[b:ca00b4e457]Abracos[/b:ca00b4e457]

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;
[/code]


Tremonti

Tremonti

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar