Autor Beitrag
kulka1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Mo 07.06.10 17:54 
Hallo,

ich hoffe ich schreibe in der richtigen Kategorie:

Ich schreibe morgen eine Klausur über Codierung und Decodierung.

Nun habe ich hier ein Programm entwickelt das eine HEX-Eingabe in BIN ausgibt:

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:
procedure TForm1.Button1Click(Sender: TObject);
var BIN : array[0..15of String;

    Eingabe, sbin : string;
    K,zhex : integer;
begin

     BIN [0] := '0000';
     BIN [1] := '0001';
     BIN [2] := '0010';
     BIN [3] := '0011';
     BIN [4] := '0100';
     BIN [5] := '0101';
     BIN [6] := '0110';
     BIN [7] := '0111';
     BIN [8] := '1000';
     BIN [9] := '1001';
     BIN [10] := '1010';
     BIN [11] := '1011';
     BIN [12] := '1100';
     BIN [13] := '1101';
     BIN [14] := '1110';
     BIN [15] := '1111';


  Eingabe := Edit1.text;
  SBIN := '';

  FOR K := 1 to length(Eingabe) do
  begin
    zhex := ord(Eingabe[K]);
    if zhex >= 65 then zhex := zhex-55
                  else zhex := zhex-48;
    SBIN := SBIN + BIN [zhex];
  end;
Memo1.Lines.Add(SBIN);
end;


Dieses Programm läuft auch.


Nun frage ich mich allerdings, wie man das am besten decodieren kann, also von BIN in HEX.

Kann mir jemand dabei helfen?
Ich hoffe meine Ausdrucksweise ist klar geworden :D.

LG kulka1
martin300
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 186
Erhaltene Danke: 2



BeitragVerfasst: Mo 07.06.10 18:26 
Hallo,
es gibt eine IntToHex Funktion in Delphi und IntToBin gibt es hier: delphi.about.com/od/...cs/a/baseconvert.htm