Page 1 of 1
Source for own packer wanted
Posted: Wed Jul 09, 2003 6:50 pm
by Ralf
I used the packlib to test to pack some datas! Really impressive! Have someone coded an own small packer in purebasic? I would like to have a small own packer (esp for packing datas with vals between $00 and $31) and learn how does it works! I know there are sources for ZIP and Co. available but i dont really understand that much.
Can someone poste his example of packing/unpacking datas or a source in any other basic language?
Btw a packer is based only on math or is it still based on routines like Strings too?
Posted: Wed Jul 09, 2003 9:34 pm
by aszid
well... here's my packer i made, it's pretty basic, and it packs files, not data. (and it does so recursively)
anyhow, this might be a start for you, enjoy.
Posted: Wed Jul 09, 2003 10:19 pm
by Edwin Knoppert
I believe JCALG is free?
www.collakesoftware.com
I had an include for PowerBASIC somewhere..
Posted: Wed Jul 09, 2003 10:22 pm
by Num3
Check tips & tricks...
I've posted the full source code for a packer system and installer system writen in Purebasic, with a bit of changes you can create a packer program for applications...

Posted: Wed Jul 09, 2003 10:33 pm
by Pupil
PureBasic uses the JCALG1 algorithm for the packer lib, no need to redo it

But it might be an interesting read though..
Posted: Wed Jul 09, 2003 10:58 pm
by aszid
umm... just call me stupid... i forgot the link in my last post -_-
viewtopic.php?t=6042&highlight=packer
it's been one of those days *sigh*
Posted: Wed Jul 09, 2003 11:15 pm
by Ralf
Mhhh... maybe there is a small mistake!? I know how to use the packer lib of PB to pack any data or files. I still want an pack algorhythm written in basic - no need of PB pack lib nor any DLL! I want to know, see and try to understand how does an good pack and unpack routine works.
I think the algo is only based on math operations or will there be any string operations too!? Any sources are welcome
Posted: Wed Jul 09, 2003 11:32 pm
by aszid
aaah i see....
well, i don't have any sources i can point you to, but i can give you a VERY simplistic rundown of how packers work. i could be wrong too... but this still might be the direction you wanted to head.
basically, what a packer does, is finds patterns. say if i have a file, and the pattern "ABCDE" shows up quite often, i can use something else to represent the "ABCDE". or say i have a file that only uses 16 of the ascii characters, i could easily cut the filesize in half by simply condensing every 2 bytes of data into a single byte.
it get's a bit clearer looking at it in the binary way.
each byte is eight 1's and/or 0's.
[edit - because my stupidity didn't end with my first post]
say i was using just the first 16 characters of the ascii table for this example.
[end of edit]
before packing:
00001010 - 00001111 - 00001011 - 00000101
after packing:
10101111 - 10110101
hope this has made some sense to you... like i said, it's VERY simplistic compared to the kinds of compression that are possible.
[edit - just to add some more ideas]
on the other hand, if you changed the base you were using to represent ascii characters (normally 8 bits) to something greater, say you made your packer use binary directly, if you made your "bytes" to be 9 bits then you could essentially pack 2x the info as a normal byte into 1.125 bytes. or you could go higher, making 10 bits contain what would normally take 24 bits.
[end of edit]
Posted: Thu Jul 10, 2003 1:52 am
by blueb
Ralf,
If you're looking for sample compression programs, please look at:
http://www.pbcrypto.com/pbcrypto.php and go down to the COMPRESSION ALGORITHMS section.
They were written in PowerBASIC but can easily be modified for Pure.
--blueb