Solved

Encrypt String!

Posted on 2000-03-13
6
349 Views
Last Modified: 2010-04-04
How to SIMPLY encrypt/decrypt strings in Memo1 when the user is saving/loading the file?
0
Comment
Question by:pipigril
6 Comments
 

Author Comment

by:pipigril
ID: 2612622
I forget to say that the file is in "plain text" format.
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 2612659
Just do this to input the data:

AssignFile(data_in, <Filename>);
Reset(data_in);
Memo1.Lines.Clear;
WHILE NOT(EOF(data_in))
DO
BEGIN
  READLN(data_in, sTemp);
  sTemp := DecodeStr(sTemp);
  Memo1.Lines.Add(sTemp);
END;
CloseFile(data_in);

And then to output the data:

AssignFile(data_out, <Filename>);
Rewrite(data_out);
FOR iCount := 0 TO (memo1.Lines.Count - 1)
DO
BEGIN
  sTemp := Memo1.Lines[iCount];
  sTemp := DecodeStr(sTemp);
  WRITELN(data_out, sTemp);
END;
CloseFile(data_out);

You'll need to create an encode and a decode routine which have a strings passed to them and then either encode or decode them. Writing these depends on how secure you want to make them. If you want help with these then just ask

The Neil
0
 
LVL 1

Expert Comment

by:umulig
ID: 2612737
You can find a lot of this stuff on WWW.TORRY.RU

Regards
Umulig
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Accepted Solution

by:
Serega earned 200 total points
ID: 2613198
There is no case what text format you are using.
You should to decode and encode whole memo text, for example as following:
// simple coding
// encoding and saving to file
var str: String;
    i:integer;
begin
     str := Memo1.Text;
     for i:=1 to length(str) do                {for all characters in string }
       str[i] := chr(ord(str[i]) xor 123);   {code character}
     Memo1.Text := str;
     Memo1.Lines.SaveToFile('e:\temp\file.txt');
     Memo1.Clear;
end;

With that coding, decoding procedure will be the same.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2613373
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2619321
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now