This forum is in archive mode. You will not be able to post new content.

Author Topic: Compression of bytes  (Read 1783 times)

0 Members and 1 Guest are viewing this topic.

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Compression of bytes
« on: October 13, 2011, 06:59:02 PM »
I have always was interested in how to compress file/information to a smaller size like using characters instead of using words (a character would stand for a word) and how to secure information like XOR encryption.

but compression was the thing I was thinking about for a long time, still doing that stuff
it all started with My calculator, yes my calculator, as I developed a program for the calculator which you could use to draw awesome painting :P(CalcPaint)
the problem is: you have a list of a max length of 999 numbers, and you need to save the X and Y components, (I could use a matrix but that needs must more space), so How I solve it? simple the screen has a size of 68 x 128 pixel
so I did the following:
Code: [Select]
X + (100/Y) --> List1[0]so coordinates were simply stored as 1 number
a normal picture would look something like this:
Code: [Select]
25,30
26,30
45,5
etc
this saved me 2 the spaced actually needed, and pictures can now be 999 pixels max, instead of the half

Lucky the calculator has 2 options:
Int and Frac
- Int would return everything that is on the left side of the comma.
- Frac does the opposition it would return everything on the right side but it would make it a whole number it would just return it as 0.30 instead of 25.30, still multiply by 100 and you got your Y component back :P
so translation back looked like this:
Code: [Select]
list1[0] -> A
Int A -> X
100Frac A -> Y
PixelOn Y,X

I yet have to find these functions on the Computer with program, but I guess string.split(Decimal.ToString(),',') will work just fine :P

after some strange Compression methods that requirs to enhance the whole program to a size of 266% and then compress it to a size of 89% of the orginal file size, but a smaller compression ration, or process speed isn't achieved
the whole method was basically this:

first take a byte turn into 8 characters take all the characters and put them after each other then make a patron into a character: and repeat until it is impossible.
Code: [Select]
255 -> 11111111
3 -> 00000011
86 -> 1010110

0000 -> A
1111 -> B
101 -> C
110 -> D
000 -> E
111 -> F
11 -> G
00 -> H
1 -> I
0 -> J
II -> K
JJ -> L
etc
so applied:
Code: [Select]
11111111000000111010110 -> BBAHGCJD
so if you would extend this kind of pattern more it would compress a lot, Decompression is just done completely Backwards

this was always an Annoying thing to do, and it wasn't really an algorithm :S

after some attempts more to do it like above I give up looked for something else,
I started to do a lot more with binary number on my calculator and made a program in which you could calculate whole list of binary commands and numbers that were depended on each other, I probably did that to understand more of CPU stuff,
turned out nice I guess, I then started more XOR and its possible content,
then ande's simple Xor Encryption came to mind, why is it possible to Encrypt and Decrypt stuff with a single key?, how can you make it more complicated?
the interseting part is once Encrypted you'll need the key to Decrypt because with that keys you had the information on what the Decrypted number is, with that key you could compare the binary numbers with each other and tell what number was hidden under it:

example
Code: [Select]
So:  10101101
Key: 01101010
     -------- Xor (True when not equel)
En:  11000111
(So = source)
now you just have that one simple number with that number you can do things
  • if you have the source you can find the key
  • if you have the key you can find the source
  • you cannot though both with doing something useless
getting the key:
Code: [Select]
So:  10101101
En:  11000111
    -------- Xor
Key: 01101010
getting source:
Code: [Select]
En:  11000111
Key: 01101010
    -------- Xor
So:  10101101
tada its magic  ;D

now I wonderd? is it possible to take 3 bytes and store 1 of them in the other 2 using Xor?
while lets try:
Code: [Select]
00000001 00000010 00000011 (1,2,3)

so we hide 3 in 1 and 2:

00000001
00000011
-------- Xor
00000010

00000010
00000011
------- Xor
00000001

so we got 10 and 01 (2 , 1)

now to convert back
00000010
00000001
-------- Xor
00000011
now we have 3 again and with this we can convert 2 , 1 back to 1, 2
add 3 after it and we have our normal byte array back 1, 2 ,3

me full excited when I first discovered this tried to do it on more different numbers:
4, 5, 6
Code: [Select]
00000100 00000101 00000110

00000100
00000110
-------- Xor
00000010

00000101
00000110
-------- Xor
00000011

so we got 1 and 3
now convert back

00000010
00000011
-------- Xor
00000001

is 1 but we used 6
as you can see its has a big problem, not everything goes as wanted T.T
as glad as I was when I first found this I also was fast disappointed in the fact that this happen T.T
I didn't sit still And the months after I tried Different methods i used And, Or, Not, Xor, Nand, Xand, Nor, but nothing all had big flaws, even combinations of those before or after it didn't matter it was all to random, I even tried it with a 4 number combination, results were the same.

I'm disappointed I couldn't find anything but I wont wait for a miracle, i'll continue to search for a method that will work.

but just let me get to the possibilities of this kind of compression,
lets do a little math: you start with 3, end with 2 you have lost 1/3

and now i you compress what you have compressed you have 1/3 of 1/3 (1/3), this means you can go on and on and on with your compress of your files,
you can compress this shit until you have hit a minimum size of 2 bytes (File Info like Name, not counted)
so in theory if your 2.0 TB External HDD is full you can Compress it, to a mere 2 bytes
and when its full of compressed files you can compress that again to a mere 2 bytes
in theory you can put any information no matter how big it is on a facking Floppy
you can put every movie every made on a floppy
heck, you can put every single bit of information on a floppy, and still have rooms to spare to do it a few times more

though the time needed to do this is probably pretty long :P but hey you could do it

though I didn't succeed in doing this, I feel very disappointed that I didn't find a method, I hope I will find it one day

« Last Edit: October 13, 2011, 08:25:14 PM by Huntondoom »
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Compression of bytes
« Reply #1 on: October 13, 2011, 07:52:38 PM »
Nice article, interesting and informative, though English could be better :D
Never the less, You sir, get +1 on this ;)
« Last Edit: October 13, 2011, 07:53:32 PM by Kulverstukas »

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Re: Compression of bytes
« Reply #2 on: October 13, 2011, 08:19:23 PM »
Nice article, interesting and informative, though English could be better :D
Never the less, You sir, get +1 on this ;)
feel free to edit, Im bad at grammar T.T
« Last Edit: October 13, 2011, 08:23:21 PM by Huntondoom »
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

Offline Deque

  • P.I.N.N.
  • Global Moderator
  • Overlord
  • *
  • Posts: 1203
  • Cookies: 518
  • Programmer, Malware Analyst
    • View Profile
Re: Compression of bytes
« Reply #3 on: October 13, 2011, 09:15:12 PM »
Quote
255 -> 11111111
3 -> 00000011
86 -> 1010110

0000 -> A
1111 -> B
101 -> C
110 -> D
000 -> E
111 -> F
11 -> G
00 -> H
1 -> I
0 -> J
II -> K
JJ -> L
Tell me, how would that work?
If you have this pattern: 1111
you can translate it to B, GG, IIII, KK, IIK, GII, IIG, ... . How do you know which it is?
« Last Edit: October 13, 2011, 09:15:54 PM by Deque »

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Re: Compression of bytes
« Reply #4 on: October 13, 2011, 10:02:25 PM »
Tell me, how would that work?
If you have this pattern: 1111
you can translate it to B, GG, IIII, KK, IIK, GII, IIG, ... . How do you know which it is?
first in line is first to get :P,
you do it by using .Replace("1111", "B")
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

PublicEnemy

  • Guest
Re: Compression of bytes
« Reply #5 on: October 14, 2011, 04:44:36 PM »
And what if someone actually wanted IIII? You would make it B. This might cause some sad faces.

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Re: Compression of bytes
« Reply #6 on: October 14, 2011, 05:01:36 PM »
you take the longest possible patron that is not really rare, because getting lost of alot of characters in one go is a good thing, You must lose as must character as possible or else you 're compression wont have any use
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

PublicEnemy

  • Guest
Re: Compression of bytes
« Reply #7 on: October 15, 2011, 01:14:07 AM »
Your compression can reduce it as much as you want, if you cant get the plain back, it is useless.

Offline Huntondoom

  • Baron
  • ****
  • Posts: 856
  • Cookies: 17
  • Visual C# programmer
    • View Profile
Re: Compression of bytes
« Reply #8 on: October 15, 2011, 11:21:29 AM »
Your compression can reduce it as much as you want, if you cant get the plain back, it is useless.
yeah for now all I can do is compress it but decompress it T.T

but it was all a theorie
« Last Edit: October 15, 2011, 11:26:14 AM by Huntondoom »
Aslong as you are connected to the internet, you'll have no privacy

Advanced Internet Search
Clean Up!

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.