Solved

File formats

Posted on 2003-12-11
15
334 Views
Last Modified: 2013-11-22
Hello,

Can anyone please point me to a tutorial,some code or at least tell me some theory on creating my own text format (like .doc , .rtf , so on) and making it unreadable by Notepad (<-- bloody thing reads everything :D :D)
Thanks alot!
0
Comment
Question by:Prototype_T-104
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9920546
That's right - it WILL load anything - it don't matter what text format you use! However, if the first two letters of the file are MZ, then WordPad won't load it (it thinks it is an exe). Notepad will load it though.

If you don't want anybody to view your data, you need to encrypt it. This can be as simple as inverting every character or as complex as 128-bit encryption they use for Internet banking and suchlike. Inverting characters is just a case of c:=Chr(255 - Ord(c));

Geoff M.
0
 
LVL 5

Expert Comment

by:-Thespian-
ID: 9920950
Try this:

-----------------------------------------------
type
  TMyCharType=record
    MChar: byte;
    MBold: boolean;
    MItalic: boolean;
.................
    MSize: byte;
  end;
  TMyFileType=file of TMyCharType;
------------------------------------------------

Read and Write file record to record (char to char) and you will have a richedit text

____________
But it is not optimized/
0
 

Author Comment

by:Prototype_T-104
ID: 9923213
Ummm could you please explain it a little bit? Thanks alot!
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Expert Comment

by:gmayo
ID: 9923250
Which one of us are you responding to?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9924109
Your's replay was clear the Thespians was a little confusing :)
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9926786
Well, to be honest, Thespian's answer is not exactly efficient. For every character in the file, there'll be 4 characters saved, ie your file will be 4x bigger than it needs to be. And you'll STILL be able to read it with NotePad.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9927060
Yes, are there any tutorials or examples on this matter??
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9927201
var f : file of TMyRec;
rec1, rec2 : TMyRec;

Write:
AssignFile(f, 'filename.txt');
Rewrite(f);
Write(f, rec1);
Write(f, rec2);
CloseFile(f);

Read:
AssignFile(f, 'filename.txt');
Reset(f);
Read(f, rec1);
Read(f, rec2);
CloseFile(f);

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9931287
So to reatin the full formatting i would have to write for each charachter their properties?!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9931331
No, that's inefficient. I'm starting to wonder exactly what you want though. Do you want something which Notepad users can't read (ie encryption) or do you want a custom text format (ie with formatting)?

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933690
Well for start a custom text format, but later if it would be a nice feature to encrypt it. So for now its just a custom text format.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 95 total points
ID: 9933790
Ok, well one way would be to use some of the control characters to control formatting. For example, use #30 to turn on bold and #31 to turn it off. All the characters in between would be bold. Another way is to use special combinations of printable characters like HTML or RTF - <B> and </B> for HTML, RTS might be something like -{Bold}- but I don't know exactly.

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933880
Hey now i am starting to get it... so i would write a parser that load each line, gets the formatting tag and formats the text accordingly!
Thanks alot so far Geoff you really are a big help!
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9933896
That's right. Just make sure that the formatting characters can't be typed by a human, causing unwanted effects. For example, you don't want somebody to type "to boldly go where..." and have everything from the LY onwards in bold!

Geoff M.
0
 

Author Comment

by:Prototype_T-104
ID: 9933908
Ok thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 101
Downloading email attachments 2 79
How to convert memory stream to PDF file 6 104
how to make 2 step back? ..\..\ ExtractFilePath (paramstr(0)) 5 48
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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