Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 27.11.05 16:48 
Hallo,

ich habe mal eine Frage:

Wie kann ich aus einem Namen (Vor- und Nachname) einen am besten Code erstellen (4 mal 5 Stellen-Blocks). Mit Buchstabe durch Buchstabe ersetzen gehts ja nicht, weil ja jeder name eine andere länge hat.
Ich brauche das für einen Trialversion-Schutz.

Weiß da wer was ?

Danke schonmal.

ciao
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 27.11.05 17:04 
vielleicht hiermit (veranschaulichter code, also noch verbesserungswürdig):
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:
function Vignere(Text, Key: string): string;
const
  vignere_quad: array [1..26] of string =
(
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'BCDEFGHIJKLMNOPQRSTUVWXYZA',
'CDEFGHIJKLMNOPQRSTUVWXYZAB',
'DEFGHIJKLMNOPQRSTUVWXYZABC',
'EFGHIJKLMNOPQRSTUVWXYZABCD',
'FGHIJKLMNOPQRSTUVWXYZABCDE',
'GHIJKLMNOPQRSTUVWXYZABCDEF',
'HIJKLMNOPQRSTUVWXYZABCDEFG',
'IJKLMNOPQRSTUVWXYZABCDEFGH',
'JKLMNOPQRSTUVWXYZABCDEFGHI',
'KLMNOPQRSTUVWXYZABCDEFGHIJ',
'LMNOPQRSTUVWXYZABCDEFGHIJK',
'MNOPQRSTUVWXYZABCDEFGHIJKL',
'NOPQRSTUVWXYZABCDEFGHIJKLM',
'OPQRSTUVWXYZABCDEFGHIJKLMN',
'PQRSTUVWXYZABCDEFGHIJKLMNO',
'QRSTUVWXYZABCDEFGHIJKLMNOP',
'RSTUVWXYZABCDEFGHIJKLMNOPQ',
'STUVWXYZABCDEFGHIJKLMNOPQR',
'TUVWXYZABCDEFGHIJKLMNOPQRS',
'UVWXYZABCDEFGHIJKLMNOPQRST',
'VWXYZABCDEFGHIJKLMNOPQRSTU',
'WXYZABCDEFGHIJKLMNOPQRSTUV',
'XYZABCDEFGHIJKLMNOPQRSTUVW',
'YZABCDEFGHIJKLMNOPQRSTUVWX',
'ZABCDEFGHIJKLMNOPQRSTUVWXY'
);
var
  i, j, count: integer;
  ukey: string;
  chx, chy: char;
begin
  result := '';
  count := 0;
  ukey := key;
  if length(key) < length(Text) then
    for i := 1 to length(Text) do
    begin
      inc(count);
      if count > length(key) then
        count := 1;
      ukey := ukey + key[count];
    end;
  if length(key) > length(Text) then
    ukey := copy(key, 1, length(Text));
  for j := 1 to length(Text) do
  begin
    chx := upcase(Text[j]);
    chy := upcase(ukey[j]);
    result := result + vignere_quad[ord(chx) - 64][ord(chy) - 64];
  end;
end;

ich mach gleich nochmal nen besseren ;)
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 27.11.05 17:35 
Bin gespannt. :D
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 27.11.05 17:40 
wobei das auch nicht wirklich hilft, habe das mal eingegeben. Leider Bekomme ich im AusgabeEdit, genau wie im EingabeEdit, bei einem Klartext-Buchstabe auch wieder nur einen Geheimtext-Buchstabe.
Ich möchte aber, dass, selbst wenn ich nur 1 Buchstabe eingebe, dass dann ein Code vom Format: XXXXX-XXXXX-XXXXX-XXXXX herauskommt. Geht das ?
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 27.11.05 17:47 
dann musst du dir selbst was basteln, aber das sollte dann schon auf verschlüsselungsverfahren beruhen, aber alles ist irgendwo durchschaubar, also solltest du das alles bissl abwandeln:
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:
function Vigenere(Text, Key: string): string;
var
  i, j, x, y, count, buf: integer;
  vignere_quad: array [1..26, 1..26] of char;
  ukey: string;
  chx, chy: char;
begin
  result := '';
  count := 0;
  for x := 1 to 26 do
  begin
    y := 1;
    for buf := x to 26 do
    begin
      vignere_quad[x, y] := chr(buf + 64);
      inc(y);
    end;
    for buf := 1 to x - 1 do
    begin
      vignere_quad[x, y] := chr(buf + 64);
      inc(y);
    end;
  end;
  ukey := key;
  if length(key) < length(Text) then
    for i := 1 to length(Text) do
    begin
      inc(count);
      if count > length(key) then
        count := 1;
      ukey := ukey + key[count];
    end;
  if length(key) > length(Text) then
    ukey := copy(key, 1, length(Text));
  for j := 1 to length(Text) do
  begin
    chx := upcase(Text[j]);
    chy := upcase(ukey[j]);
    result := result + vignere_quad[ord(chx) - 64][ord(chy) - 64];
  end;
end;

indem die hier, das quadrat nicht alphabetisch auffüllst sondern anders, QHRCOPLDME anstatt ABCDEF, da steigt dann keiner so leicht hinter.

zu dem format problem hab ich das gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function CDKey(Seed:String): String;
const Key1: Array[0..9] of Char = ('2','5','8','9','5','a','1','3','6','7');
      Key2: Array[0..9] of Char = ('8','3','4','0','1','7','x','9','3','9');
var i: integer;

begin
 result := Seed + '-';

 for i:= 1 to length(Seed) do
  result := result + Key1[Ord(Seed[i])-48];

 result := result + '-';

 for i:= 1 to length(Seed) do
  result := result + Key2[Ord(Seed[i])-48];

end;

...

 if CDKey(Copy(Eingabe.Text,1,4)) = Eingabe.Text then
  Caption := 'Richtig' else Caption := 'falscher Key';

aus dem easy helper, aber so dolle ist der code net, naja ein denkanstoß allemal ;)
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: So 27.11.05 18:07 
Jo, das ist schon net schlecht. Aber wie gesagt, meine Frage zielte eher nicht auf eine Zeichenzuordnung ab, sondern darauf, wie ich aus einem Namen einen Key des Formates XXXXX-XXXXX-XXXXX-XXXXX bekomme. Weißt du darüber wat ?
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 27.11.05 18:13 
genau das macht function CDKey(Seed:String): String; doch, oder bin ich im irrtum ? Für mich sieht das stark danach aus ;)
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: So 27.11.05 19:10 
Hi,

wie wäre es, wenn du MD5 nehmen würdest? Da hättest da zwar nicht die Form XXXX-XXXX-XXXX-XXXX, aber da ist es sicher, dass du immer die gleiche Form kriegst. So kannst meinetwegen den Vornamen und Nachnamen als String aneinanderhängen, dann den MD5-Hash berechnen und dieser ist der Key. Nur musst die mehrmals aneinanderhägnen oder buchstaben vertauschen oder so, weil sonst wäre es zu einfach und man könnte den Key selber berechnen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 27.11.05 19:32 
Dann würde ich den Namen mit Vigenere verschlüsseln (siehe oben) und anschließen mit MD5 verschlüsseln.
Dann bekommst du einen Key mit immer gleicher Länge. Denn kannste dann noch aufteilen und mit - trennen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)