Autor Beitrag
marvin521993
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Do 25.01.07 19:00 
hi,

meine frage ist wie ich ein verschlüsselten text in einem memo in einem anderen memo ausgeben kann!!!
kann mir da jemand helfen?
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Do 25.01.07 19:07 
Du liest von jeder Zeile in Memo1 jedes Zeichen ein, verschlüsseltst/entschlüsselst es und fügst es in Memo2 wieder ein.
marvin521993 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Do 25.01.07 19:22 
jaja dis is mir schon klar meine frage is eher die wie ich ihm das beibringen kann
DarkLord05
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 449

WinXP Pro SP2
Opera; Delphi 3 Pro; Delphi 2005, Turbo Delphi, dev-c++, Eclipse, MS Visual Studio .NET 2003, MS Visual C++
BeitragVerfasst: Do 25.01.07 19:44 
Funktion 1: Ord()
Funktion 2: Chr()


Damit kannst du zeichen umwandeln in ASCII (sind zahlen), dieses machst du einfach, zählst 13 zu den zahlen und gehst zum nächsten Buchstaben. Zurück geht genauso ... nur halt nicht 13 dazu, sondern -13. Fertig

_________________
QBasic | Delphi | c++ | PHP | C# .NET | Java
marvin521993 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Fr 26.01.07 16:12 
kann mir da jemand ein quelltext geben?

danke
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 26.01.07 16:16 
nur wenn du versprichst das du dich damit beschäftigst! nicht das wir deine aufgabe machen!!

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
marvin521993 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Fr 26.01.07 16:19 
ja dis würd ich sowieso machen sonst würds mir ja eh nichts bringen

danke:-)
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 26.01.07 16:19 
Jetzt hat mir elundril meinen Text vorweggenommen ... :roll:
Du lernst nicht aus fertigem Quelltext! Besser ist es, wenn du dir das Zeug selbst aneigenest, wobei wir die höchstens ein paar Hilfestellungen geben. ;)

//edit: wenn du aber darauf bestehst, dir fertigen Quelltext anzuschauen, kann ich dir auch ausnahmsweiße meinen geben :)


Zuletzt bearbeitet von Marc. am Fr 26.01.07 16:22, insgesamt 1-mal bearbeitet
marvin521993 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Fr 26.01.07 16:22 
ich hab da echt keine ahnung wie ich da anfangen sollte
und was ich dem dann alles genau sagen muss
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 26.01.07 16:25 
Das ist meine Funktion:
ich bin mal essen - danach erläutere ich sie dir mal ;)
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:
23:
24:
25:
26:
function VS(Text: string; i: integer): string;
const
  cletter: array[1..26of Char =
  ('A''B''C''D''E''F''G',
    'H''I''J''K''L''M''N''O',
    'P''Q''R''S''T''U''V''W''X''Y''Z');
var
  x, z: integer;
begin
  Result := '';
  text := uppercase(Text);

  for x := 1 to length(Text) do
    begin
      if not (Text[x] in ['A'..'Z']) then
        result := result + Text[x]
      else
        for z := 0 to 26 do
          if (Text[x] = cletter[z]) then
            if ((Z + i) > 26then
              Result := Result + cletter[(z + i) - 26]
            else
              Result := Result + cletter[z + i]
    end;
  result := lowercase(result);
end;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 26.01.07 16:27 
So ersetzt man alle A's in einem Memo durch ein B und zeigt das im zweiten Memo an:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
  str: String;
begin
  str := Memo1.Text;
  for i := 0 to length(str) - 1 do
  begin
    if str[i] = 'A' then
      str[i] := 'B';
  end;
  Memo2.Text := str;
end;
So mal als Einstieg in das Thema.
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 26.01.07 16:27 
also mit einer For-Schleife die von dem anfang bis zum ende läuft kannst du jedes Zeichen auslesen.
ausblenden Delphi-Quelltext
1:
2:
3:
  for Index:=iAnfang to iEnde do begin
    {jetzt kommt die verschlüsselung}
  end;


mit einer Rechteckigen klammer am ende von einen string bekommst du das zeichen an der position vom string. Also:
ausblenden Delphi-Quelltext
1:
2:
  // cZeichen ist ein typ Char und sMyString vom Typ String
  cZeichen:=sMyString[index];


dabei muss man sich in erinnerung rufen das man mit
ausblenden Delphi-Quelltext
1:
  Memo1.text;					

den text von Memo in einem string bekommt.

und das ganze kann man mit
ausblenden Delphi-Quelltext
1:
  sAusgabestring:=sAusgabestring+cZeichen;					

wieder zusammensetzen.


so jetzt weißt du alles was du brauchst. viel spass beim Basteln!!

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 26.01.07 16:39 
user profile iconGausi hat folgendes geschrieben:
So ersetzt man alle A's in einem Memo durch ein B und zeigt das im zweiten Memo an: [...]
ausblenden Delphi-Quelltext
1:
2:
3:
4:
str: String;
begin
  str := Memo1.Text;
  for i := 0 to length(str) - 1 do

Ein String beginnt immer bei 1 und nicht bei 0 oder irre ich mich da? :roll:
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 26.01.07 16:41 
stimmt! aber eigentlich egal da der compiler keine Exeption auswirft. der übergeht das einfach!!

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Fr 26.01.07 16:42 
Ja, aber das letzte Zeichen wird dann missachtet! ;)
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Fr 26.01.07 16:44 
stimmt glaub ich auch nicht da die obere grenze gleich bleibt.

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
marvin521993 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 172



BeitragVerfasst: Fr 26.01.07 16:59 
irgendwo muss ich doch jetz bei der formel von gausi ein lowercase einführen nur an welchter stelle?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Sa 27.01.07 13:38 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject); 
var i: integer; 
  str: String
begin 
  str := lowercase(Memo1.Text); // hier würd ich sagen wenn du den text klein haben magst
  for i := 0 to length(str) - 1 do 
  begin 
    if str[i] = 'A' then 
      str[i] := 'B'
  end
  Memo2.Text := str; 
end;

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Grenzgaenger
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 27.01.07 14:39 
user profile iconMarc. hat folgendes geschrieben:
Ein String beginnt immer bei 1 und nicht bei 0 oder irre ich mich da? :roll:


tja, nicht immer. null terminierte strings beginnen bei 0
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 27.01.07 14:58 
Ja, die normalen Strings, die man so bei Delphi findet, beginnen bei 1, d.h. das erste Zeichen eines Strings kann man mit meinString[1] ansprechen.
Die nullterminierten Strings findet man afaik eher in der C-Welt, oder wenn man mit der Windows-Api arbeitet. Die Dinger heißen dann PChar.

Insofern war der Einwand zu meinem Code berechtigt. :oops:

_________________
We are, we were and will not be.