Solved

Encrypt String!

Posted on 2000-03-13
6
351 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

803 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