Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / creating my own file type

Author
Message
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 6th Jul 2004 12:30 Edited at: 10th Jul 2004 10:42
-------------------------------------------------
I changed the topic of this thread, all though still along the same line. Please read the 7th post on this thread and reply to that one
-------------------------------------------------





I am attempting to write a program that I can use to create a journal for myself containing text and pictures and other things.

I could do this without any coding knowledge whatsover and I know that Darkbasic isn't really mae for this type of a project but I want my journal to be contained all in one file, safe and secure from the prying eyes of others due to the fact that no other program besides mine can read my file type, and I also am not versed nearly enough in any other languageto even begin attempting something like this yet.

So here I am asking for help:

First of all as far as I know there is no way that you can open an already existing file and add to it. There is the "Open to write" command but it will fail if the file exists! So I have to do a voodoo dance copying the file contents to a memblock (which is my next problem), deleting the file, using the "open to write command" after the file is deleted, and then copying the memblock back into the file just so I can add another entry!

Then there is copying a files contents into a memblock. Unless I use the "write memblock" command to write a memblock directly to a file, I can't use the "read memblock" command to get the information directly out of the file! This means I get to jump through more hoops using a "for x=0 to blahblahblah" loop reading and writing every single byte (and this can get very confusing).

I just want to be able to add to a file that already exists in a simple, non confusing, non habit forming way so that I can chronicle my sad, computer centered life.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 6th Jul 2004 15:10
Well, think of it like this...

When you enter an entry into the dev-diary, you're going to want to be able to read it again, along with all your previous entries, so, you're going to have to read the entire file in anyway.

You will want to come up with your own file format.

I suggest making something simple like:


Then to make it so that it can't just be read through notepad, do a really simple encryption system such as shifting the ascii codes to +1 ( confuses the hell outta anyone just trying to open it up and read it ).

You'll have to have someway of formatting your text, and making it so that you can tell where there is an image ( in this case, I denoted an image with the "[" and "]" tags. )

If you need more help, or an example, I'm glad to help, But I'd prefer if you gave it a shot yourself first.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 6th Jul 2004 18:56
omg! lol! wow! I was thinking the exact same thing with the brackets denoting images and the only difference between you and me on the ascii code changes was that I was thinking more along the lines of +17 because 17 is a really cool number!

Formating is the easy part, my problem really is the coding logistics. For example:

If I do create my own file from a memblock and I want to add another entry so I turn the file into a memblock again, I now have a memblock that I cannot add data to because it has no more room so I have to create a second memblock to do that in, then I have to create a third memblock so I can paste the second memblock to the end of the first and save it as the original file which I can't do until I delete the original file because you can't write to a file that has already been created! *whew*

Then to top all that off, unless I want to create my own subroutine mimicking DarkBASIC's "make memblock from image" command I have all these little seperate memblocks that I have to stick into the file and I don't believe that I can take all the memblocks out again using the "read memblock" command because they are after all seperate memblocks.

I'm going to be tinkering but unless the power of god drops a new set of commands that make my job easier eight into my lap, I am going to be spinning my tires, running in circles, going nowhere fast, and chasing my tail. (All at the same time btw.)
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 7th Jul 2004 20:40
I want to bump you like a stumped coder
I want to feel you from the server side
I want to bump you like a stumped coder
My coding experience is flawed
You get me closer to angry

Butchered Nine Inch Nails "Closer", but one heckuva bump at 3:40 A.M.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 7th Jul 2004 22:46
What I suggest is that you have seperate files for each entry...

It'll make your codeing alot easier, and all you have to do then is sipmly create a new file for each new entry.

It will also mean that when you load up your program, and you want to read past entry's, you don't end up loading in ALL the entry's from two years previous, which would a) kill your memory, and b) slow your app to a stop.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 8th Jul 2004 04:34
Jess is on the right track, seperate files for eache entry would keep the memory drain to a minimum, you could also do it this way, to save on memory, open the file as it is to date, then write it to another file (called for example "temp") then add to that file any alterations you need and write them to the file as you make them, then close the file when the program exits and delete the original file, then save the temp file as the "project" file and delete the temp file, just one memblock would waste memory and would keep growing until it ate all the memory the system had, just make you own file format/system using open to write and open to read, where (for example) chr$255 marks the end of an entry, then you can scan through the file day by day (stopping when you hit Chr$255), and add bits in if you like, when you want to edit an entry then make a new file, write all the entries up to the day you edited, then write the edited file in place of it, then write the rest of the files,delete the original file and then rename the new file, that way all you need to hold in memory is the day you looking at/editing, you can store all sorts of data in the same file, images,music etc, all you need to do is use non ascii codes to mark where the picture data starts and ends, where the text starts/ends, same for video, music etc, just encode the whole lot as a file and write that to disk, I will cobble up an example if you can`t make sense of my ramblings, cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 10th Jul 2004 10:41
Ok, using seperate files for each entry doesn't sound like a half bad idea.

Now on to the encryption. I know that my journal isn't a top secret classified document and just adding +17 to the ascii code will keep it out of almost anyones hands but I am paranoid and I want to pass this idea by yall and see if you can think of a way to crack it (because I can't)

the first 10 bytes of each journal entry file tells my program how the file is encrypted and consists of the ascii code if my password (yes I'm going to password protect my program, duh) and random numbers between 1 and 255

Example:
for the example my password is "dude". "dude" is not 10 charicters long so we'll fix that for the encryption and make it "dudedudedu" (use the program to repeat the password until it's exactly 10 charicters long). Then add to the ascii of each letter in the password a random number between 1 and 255 (of course I'll use a wrap command so that the final value of each byte isn't less than 0 or more than 255).

If you're with me so far now we have 10 bytes that are made up of my password and 10 random numbers. How does that encrypt my file? The random numbers will encrypt it:

Example: The first random number (say 12) will be added to the first actual byte of the journal log, the second random number will be added to the second byte, the third to the third byte.

The thing is that the program will not know what random numbers to use to decrypt the file unless it's told what the password is so that it can subtract the password ascii numbers from the first 10 bytes to get the random numbers used to encode the file. And the program can't figure out what the password is because it deosn't know what the random numbers are to subtract to get the password ascii.

please post if you follow me, or even if you don't, as long as you have questions.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 10th Jul 2004 15:04
Yeah, that sounds good.

But, was that a question asking how to actually code it, or was it a statement saying that you're going to do it that way? lol.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 10th Jul 2004 18:33
It was a question, whether or not you could find a way to break it. If no one can then I will code it that way

I think my skillz are up to writing that if it can pass the breakability test
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 11th Jul 2004 00:29
Oh, it's breakable... All encryption's breakable... just cos it takes over 20 years for a home PC to break it doesn't mean it's not breakable.

But, that sounds like is should be pretty darn secure if you're certain that non-security proffessionals will be trying to get into your journals... For whatever reason.

To increase the security, try making a longer password, and have a different pass for each file. And double up the randomness, ie, the 8th byte has the 8th random byte added to it, and then has the 1st random byte subtracted from it, the 9th byte has the 9th random byte added to it, and the 2nd random byte subtracted from it, the 10th byte has the 10th random byte added to it, and the 3rd random byte subracted from it, and then the 11th byte has the 4th random byte added to it, and then the 12th byte has the 5th random byte added to it...

Anyway, you get the idea.

Lol.

Yeah, that's pretty darn secure, I would say.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Sleet
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location:
Posted: 12th Jul 2004 20:42
I realize that there is a lot that I don't understand and this encryption is probably breakable but for the life of me I can't understand how it could be lol

For instance it is possible due to the randomness and sheer luck that the word "hand" could be coded (ascii code wise) to be: "aaaa"

Then again, without knowing either the random numbers or the password it leaves me scratching my head as to how someone would seperate the two.

And THAT is even with handing them the priceless piece of knowledge that the first 10 bytes are a combination of random numbers used to encode the file added to the ascii of the password.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 12th Jul 2004 23:32
Sleet, you're starting to get paranoid here.

The code will not be broken, don't worry. I don't think Bill Gates is going to jump into your computer, decrypt your personal logs and set the dogs loose on you becuase you said a bad word about him, lol.

Do a sample code, and then post it into the General section, and see if it can get broken. Drop some hints if noone can get it straight away.
People on this forum love logic puzzels like that.

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-24 23:06:40
Your offset time is: 2025-05-24 23:06:40