Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Job-Börse: Angebote und Gesuche (https://www.delphipraxis.net/66-job-boerse-angebote-und-gesuche/)
-   -   JAVA Encryption in Delphi umsetzen (https://www.delphipraxis.net/187005-java-encryption-delphi-umsetzen.html)

Ajintaro 20. Okt 2015 11:09


JAVA Encryption in Delphi umsetzen
 
Hallo,

ich habe eine JAVA-Verschlüsselungsroutine erhalten und möchte dies mit der Chillkat Komponente umsetzen.
Ich kann es leider nicht selbst umsetzen und wollte an dieser Stelle nach jemandem suchen, der es für mich umsetzen kann.

Was ich liefern kann:
  • Chillkat Komponente
  • Delphi Demo mit funktionierender AES Verschlüsselung
  • JAVA-Routine mit Quelltexterläuterungen

Was ich brauche:
  • Umsetzung der JAVA-Routine in Delphi (DEC oder Chillkat Library)

Method
AES/CBC/PKCS5Padding

Secret Key
128bits

Initialization Vector
  • requires to have 128bit (Same length as the blocks in AES)
  • IV used during encryption should be added in front of encrypted data
  • new IV should be generated for each encryption

Encrypted token format
The process to build the token from encrypted data is:
  1. Compute SHA1 of the 4 first bytes of the encryption key
  2. create the part to be signed by concatenating:
    • 0x00
    • 4 first bytes of SHA1 computed in Step 1
    • Encrypted data
  3. Using HmacSHA1 of the encryption key, sign the block of data generated in Step 2
  4. Concatenate block of data from step 2 with the one from step 3
  5. Encode using base 64 the block generated in previous step

Falls jemand Zeit und Lust hat, schreibt mich bitte per PN oder Email (the_summoner@hotmail.com) an und wir besprechen dann die Details.

totti14 20. Okt 2015 12:54

AW: JAVA Encryption in Delphi umsetzen
 
Hallo Ajintaro,
evtl. solltest du dir mal die DCPcrypt Units anschauen.
Macht genau das gleiche wie die Chillkat Kompo.
Sehr einfach zu handhaben.

Gruß
totti

Ajintaro 27. Okt 2015 13:45

AW: JAVA Encryption in Delphi umsetzen
 
Hi DP,

mein Thread hat sich erledigt, hat es selbst hinbekommen :wink:

BUG 27. Okt 2015 14:01

AW: JAVA Encryption in Delphi umsetzen
 
Zitat:

Zitat von Ajintaro (Beitrag 1319849)
mein Thread hat sich erledigt, hat es selbst hinbekommen :wink:

Super :thumb:
Wenn du das Ergebnis teilst, haben auch noch nachfolgende Generationen was davon, falls sie mit der Suche darauf stoßen.

Ajintaro 28. Okt 2015 07:47

AW: JAVA Encryption in Delphi umsetzen
 
Hallo,

ich habe als kurzfristige Lösung einfach die JAVA-Datei um eine Auswertung von Start-Parametern erweitert und rufe diese mit folgender Funktion auf:

Delphi-Quellcode:
{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//GetDosOutput
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
function GetDosOutput(CommandLine: string; Work: string = 'C:\'): string;
var
  SA: TSecurityAttributes;
  SI: TStartupInfo;
  PI: TProcessInformation;
  StdOutPipeRead, StdOutPipeWrite: THandle;
  WasOK: Boolean;
  Buffer: array[0..255] of AnsiChar;
  BytesRead: Cardinal;
  WorkDir: string;
  Handle: Boolean;
begin
  Result := '';
  with SA do begin
    nLength := SizeOf(SA);
    bInheritHandle := True;
    lpSecurityDescriptor := nil;
  end;
  CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
  try
    with SI do
    begin
      FillChar(SI, SizeOf(SI), 0);
      cb := SizeOf(SI);
      dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
      wShowWindow := SW_HIDE;
      hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
      hStdOutput := StdOutPipeWrite;
      hStdError := StdOutPipeWrite;
    end;
    WorkDir := Work;
    Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
                            nil, nil, True, 0, nil,
                            PChar(WorkDir), SI, PI);
    CloseHandle(StdOutPipeWrite);
    if Handle then
      try
        repeat
          WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
          if BytesRead > 0 then
          begin
            Buffer[BytesRead] := #0;
            Result := Result + Buffer;
          end;
        until not WasOK or (BytesRead = 0);
        WaitForSingleObject(PI.hProcess, INFINITE);
      finally
        CloseHandle(PI.hThread);
        CloseHandle(PI.hProcess);
      end;
  finally
    CloseHandle(StdOutPipeRead);
  end;
end;
Beispielaufruf:

Delphi-Quellcode:
Memo1.Text := GetDosOutput('java -jar myjarfile.jar parameter1 parameter2",ExtractFilePath(Application.Exename));

Das ist zwar keine saubere Delphi-Umsetzung wie ich sie gerne hätte, funktioniert aber erst mal.


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:29 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz