Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Text verschlüsseln ohne kömische Symbole ! (https://www.delphipraxis.net/113398-text-verschluesseln-ohne-koemische-symbole.html)

Delphiturbo 7. Mai 2008 11:33


Text verschlüsseln ohne kömische Symbole !
 
Hallo,

hier ist eine einfache Funktion. Sie verschlüsselt den Text aber ich erhalte
mansch mal keine deutsche Buchstaben
z.B. : 12345 bekomme ich 5J fQ !!!

Wo soll ich den Code ändern, damit ich immer normale Tastatur Symbole
damit jeder das Ergebnis eintippen kann :mrgreen:
Delphi-Quellcode:
function strEncrypt(const S: String; Key: Word): String;
var I: Integer;
const C1 = 52845; C2 = 22719;
begin
{$IFDEF Win32} 
 SetLength(Result,Length(S));
{$ELSE} 
 Result[0]:=Chr(Length(S));
{$ENDIF} 
 for I := 1 to Length(S) do begin
  Result[I] := Char(Ord(S[I]) xor (Key shr 8));
  Key := (Ord(Result[I]) + Key) * C1 + C2;
 end;
end;

generic 7. Mai 2008 12:00

Re: Text verschlüsseln ohne kömische Symbole !
 
die binäre Ausgabe von deine Code könntest du durch einen Base64 Encoder/Decoder jagen.

SirThornberry 7. Mai 2008 12:02

Re: Text verschlüsseln ohne kömische Symbole !
 
oder das ganze in hexdecimaler Darstellung ausgeben.

Klaus01 7. Mai 2008 12:05

Re: Text verschlüsseln ohne kömische Symbole !
 
Hallo,

für solche Sachen hat sich eigentlich die Hexdarstellung durchgesetzt.

Delphi-Quellcode:
function strEncrypt(const S: String; Key: Word): String;
  var
    I: Integer;
    dummyKey: Byte;
  const
    C1 = 52845; C2 = 22719;
begin
  result := '';
  for I := 1 to Length(S) do
    begin
      dummyKey :=Ord(S[I]) xor (Key shr 8)
      Result := result + IntToHex(dummyKey,2);
      Key := (dummyKey + Key) * C1 + C2;
   end;
end;
Grüße
Klaus

Delphiturbo 7. Mai 2008 12:18

Re: Text verschlüsseln ohne kömische Symbole !
 
Finde ich mit Hex
und was ist mit :
Delphi-Quellcode:
function strDecrypt(const S: String; Key: Word): String;
/// !

Klaus01 7. Mai 2008 12:20

Re: Text verschlüsseln ohne kömische Symbole !
 
Delphi-Quellcode:
DeinValue:= StrToInt('$'+<hexString>);
Grüße
Klaus

Delphiturbo 7. Mai 2008 12:35

Re: Text verschlüsseln ohne kömische Symbole !
 
Zitat:

Zitat von Klaus01
Delphi-Quellcode:
DeinValue:= StrToInt('$'+<hexString>);

wo kommt das???

Klaus01 7. Mai 2008 12:36

Re: Text verschlüsseln ohne kömische Symbole !
 
Zitat:

Zitat von Delphiturbo
Zitat:

Zitat von Klaus01
Delphi-Quellcode:
DeinValue:= StrToInt('$'+<hexString>);

wo kommt das???

im decrypt...

Grüße
Klaus

grenzgaenger 7. Mai 2008 12:49

Re: Text verschlüsseln ohne kömische Symbole !
 
oder du verwendest 'n algo, der keine ungültigen zeichen erzeugt. z.b. cäsar codierung.

<HTH>

btw: ist der XOR eine sehr schwache codierung.

Delphiturbo 11. Mai 2008 15:09

Re: Text verschlüsseln ohne kömische Symbole !
 
Zitat:

Zitat von Klaus01
Delphi-Quellcode:
DeinValue:= StrToInt('$'+<hexString>);

Geht nicht !!!
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
    Edit2.Text:=strEncrypt(Edit1.text, 1258); // ok
    Edit3.Text:= // hier soll wieder entschlüsselt !
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:19 Uhr.
Seite 1 von 3  1 23      

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