Autor Beitrag
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Mi 19.04.06 14:45 
Für mein aktuelles Projekt:
www.delphi-forum.de/...Editor+13_57179.html
suche ich jetzt einen bestimmten Verschlüsselungs Algorithmus.
Natürlich hab ich mich schon ein bisschen schlau gemacht(ua Wikipedia) jedoch war nichts für mich dabei.

Alle Algorithmen die ich gefunden habe verändern in irgendeiner Weise die Zeichen....
ausblenden Quelltext
1:
2:
unverschlüsselt:Andre
verschlüsselt:wrtze

allerdings suche ich ein der nicht die Buchstaben an sich verändert sondern "nur" deren Position...
ausblenden Quelltext
1:
2:
unverschlüsselt:Andre
verschlüsselt:ndrAe


welche kann man da einsetzen?

_________________
GEIZ IST GEIL! - Ihr Sozialamt
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 19.04.06 14:48 
Programmiere das doch selber.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
starsurfer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Mi 19.04.06 14:51 
Würd ich ja gerne, aber mir fehlt der Ansatz wie ich die Zeichen vertauschen könnte abhängig vom PW.

Der Delphi Code ist sicher nicht das Problem, aber ein Ansatz muss man ja vorher haben :)

_________________
GEIZ IST GEIL! - Ihr Sozialamt
Sy-
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177



BeitragVerfasst: Mi 19.04.06 15:02 
Dann streng dich an :wink:

Was hälst du davon, deinen Zeichen, die du im Passwort verwendest gewisse Zahlen zuzuordnen
zB:
Test = 71 84 2 93

Nun gehst du hin und versetzt es prozentual zum gesamttext.
Beim ersten Zeichen im verhältnis zu 71, dann 84 usw und das immer wieder von neu mit allen zeichen.

Da kannste dann noch weitere Clous einbauen.

Das decoden geschieht natürlich rückwärts, wobei du beachten solltest, dass du vorher ausrechnen musst, bei welchem Zeichen deines Passworts er dann aufgehört haben muss.

Denke das sollte schonmal ein guter Ansatz sein.
Gruß
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 19.04.06 15:05 
So erstellt man eine Permutation:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Function NthPermutation (const aString : AnsiString; aCount : Integer) : AnsiString;
Var
  pos, i, n : Cardinal;
  chTemp : char;
Begin
  n := Length(aString);
  result := aString;

  for i := n downto 2 do
    begin
    pos := acount mod i +1;
    //switch
    chTemp := result[i];
    result[i] := result[Pos];
    result[Pos] := chTemp;

    acount :=  acount div i;
    End;
End;

'aCount' ist dabei eine Zahl zwischen 0 und N!-1, wobei N die Anzahl der Zeichen im String 'aString' ist.

Du musst Dir also eine Funktion schreiben, die Dir aus dem Passwort diese Zahl erzeugt. Eine einfache Möglicheit wäre einfach:
ausblenden Delphi-Quelltext
1:
2:
3:
N := Length (myPassword);
Nf := Fakultaet(N); // Selber schreiben !
aCount := CRC16 (myPassword) mod Nf; // CRC16 findest Du hier auch irgendwo

_________________
Na denn, dann. Bis dann, denn.
Sy-
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 177



BeitragVerfasst: Mi 19.04.06 15:42 
Verstehe ich das richtig, dass es dann nur 10 Varianten bei einem 10 Stelligen Text gibt?
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 19.04.06 15:46 
user profile iconSy- hat folgendes geschrieben:
Verstehe ich das richtig, dass es dann nur 10 Varianten bei einem 10 Stelligen Text gibt?

Nein, es gibt 10!, also 10*9*8*7*6*5*4*3*2 Varianten, also ein bisschen mehr als 10.
[edit]Die 8* wurde vergessen :oops: [/edit]

_________________
Na denn, dann. Bis dann, denn.


Zuletzt bearbeitet von alzaimar am Mi 19.04.06 16:03, insgesamt 1-mal bearbeitet
Horst_H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1654
Erhaltene Danke: 244

WIN10,PuppyLinux
FreePascal,Lazarus
BeitragVerfasst: Mi 19.04.06 15:48 
Hallo

es gibt 10!=1*2*3*4*5*6*7*8*9*10=3628800 Varianten

Gruss Horst
Sirke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 208
Erhaltene Danke: 2



BeitragVerfasst: Mi 19.04.06 17:38 
In der Kryptographie heißt das, was du suchst Transposition.

Der untere Artikel sollte dir helfen, das ganze von einem Passwort abhängig zu machen:

Zitat:
To perform a single columnar transposition we write out the key as column header. The key is numbered in alphabetical order. If two letters of the key are the same, the first in the key gets the lowest number.

Plain text: THIS IS A SECRET MESSAGE
Key : LEONARDO

The plain text is written out in successive rows beneath the headers:

L E O N A R D O
4 3 6 5 1 8 2 7
---------------
T H I S I S A S
E C R E T M E S
S A G E

De code message is read off in columns in order of the headers, and written in groups of five letters:

Cipher text: ITAEH CATES SEEIR GSSSM

To decode the message we write out the header and reconstruct the table with long and short rows. We fill in the code column by colum in the order of the key.


mfg Sirke
starsurfer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Do 20.04.06 19:29 
genau das mit der Transposition hab ich gesucht :wink:

Danke an Sirke und natürlich an die andren :)

das ist jetzt bei raus gekommen:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
function codieren(pw,txt:string):string;
var rest,i,j,help,pos:integer;
    reihenfolge,werte:array of integer;
    max_wert:array[0..1]of integer;
begin
//Textlänge anpassen
txt:=stringreplace(txt,#13#10,#13,[rfreplaceall]);
rest:=length(txt) mod length(pw);
if rest>0 then
   begin
   for i:=1 to length(pw)-rest do
       txt:=txt+' ';
   end;
//Textlänge anpassen
//PW auflösen
setlength(reihenfolge,length(pw));
setlength(werte,length(pw));
for i:=1 to length(pw) do
    werte[i-1]:=ord(pw[i]);
help:=1;
for i:=0 to length(pw)-1 do
    begin
    max_wert[0]:=256;
    for j:=0 to length(pw)-1 do
        begin
        if max_wert[0]>werte[j] then
           begin
           max_wert[0]:=werte[j];
           max_wert[1]:=j;
           end;
        end;
    werte[max_wert[1]]:=256;
    reihenfolge[max_wert[1]]:=help;
    inc(help);
    end;
//PW auflösen
//Text splitten
for i:=0 to length(pw)-1 do
    begin
    j:=0;
    while reihenfolge[j]-1<>i do inc(j);
    pos:= j+1;
    while length(txt)+1>pos do
          begin
          result:=result+txt[pos];
          pos:=pos+length(pw);
          end;
    end;
//Text splitten
end;

function decodieren(pw,txt:string):string;
var i,j,help,pos:integer;
    reihenfolge,werte:array of integer;
    max_wert:array[0..1]of integer;
begin
//PW auflösen
txt:=stringreplace(txt,#13#10,#13,[rfreplaceall]);
setlength(reihenfolge,length(pw));
setlength(werte,length(pw));
for i:=1 to length(pw) do
    werte[i-1]:=ord(pw[i]);
help:=1;
for i:=0 to length(pw)-1 do
    begin
    max_wert[0]:=256;
    for j:=0 to length(pw)-1 do
        begin
        if max_wert[0]>werte[j] then
           begin
           max_wert[0]:=werte[j];
           max_wert[1]:=j;
           end;
        end;
    werte[max_wert[1]]:=256;
    reihenfolge[max_wert[1]]:=help;
    inc(help);
    end;
//PW auflösen
//Text splitten
help:=trunc(length(txt)/length(pw));
for pos:=1 to help do
    begin
    for j:=0 to length(pw)-1 do
        begin
        result:=result+txt[pos+(reihenfolge[j]-1)*help]
        end;
    end;
//Text splitten
end;


*die Functionen können jetzt mit Zeilenumbrüche(#13#10) umgehen...

_________________
GEIZ IST GEIL! - Ihr Sozialamt


Zuletzt bearbeitet von starsurfer am Fr 21.04.06 12:33, insgesamt 1-mal bearbeitet
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 21.04.06 11:49 
Ersetz doch einfach vor der Kodierung #13#10 durch #13 und danach wieder zurück ... Dann hast Du auf jeden Fall immer #13#10 als Zeilenumbruch drin und der Zeilenumbruch wird nicht in seine einzelteile zerlegt.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
starsurfer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Fr 21.04.06 12:35 
so was in der Art is mir auch schon vorgeschwebt* :)
*(aktuelle Functionen ein Post weiter oben)

na da werd ich mich mal ans optimieren machen ....

_________________
GEIZ IST GEIL! - Ihr Sozialamt