Würde gerne Daten in der Database verschlüsselt speichern,
und im StringGrid wieder entschlüsselt darstellen.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
i:integer;
begin
//Test Text
s:='Dies ist ein Test';
for i:=1 to length(s) do begin
s[i]:=Chr((Ord(s[i]) Xor (i*i-i))+(3+i)*(5+i));
Memo1.text := s; // Test Memo1 Ansicht
end;
MyTAble1.Insert;
MyTAble1.Edit;
MyTable1.FieldByName('Eingabe').Text := s;
MyTAble1.Post;
MyTAble1.Refresh;
DBGrid1.Refresh; // Daten verschlüsselt speichern
for i:=1 to length(s) do begin
s[i]:=Chr((Ord(s[i])-(3+i)*(5+i)) Xor (i*i-i));
end;
//Endschlüsseln und im StringGrid kopieren
StringGrid1.FixedCols := 0;
StringGrid1.FixedRows := 1;
StringGrid1.ColCount := MyTable1.FieldCount;
StringGrid1.RowCount := MyTable1.RecordCount+1;
Memo2.text:= s; // Test Memo2 Ansicht
for i := 0 to MyTable1.FieldCount - 1 do begin
StringGrid1.Cells[i,0] := MyTable1.Fields[i].DisplayName;
end;
MyTable1.First;
while not MyTable1.Eof do begin
for i := 0 to MyTable1.FieldCount - 1 do begin
StringGrid1.Cells[i, MyTable1.RecNo] := MyTable1.Fields[i].AsString;
end;
MyTable1.Next;
end;
end;