Re: Preventing large runs of identical bits.
- From: NickHolby@xxxxxxxxxxxxxx
- Date: 18 Apr 2007 04:25:14 -0700
xor everything by 01010101? :)
Well, that is a possibility. Although for some strings that are
already 'random appearing', it will make them all constant. Is there a
way I can xor the xor result, and repeat that process X times, so that
the chance of that input string creating a constant bit string
minimal?
----------------------------------------------------------------------
What about xoring the data against a pseudo-random generated stream?
This way, the operation is undoable, as long as you store the seed
with the resulting data so you can re-generate that exact pseudo-rand
stream for restoring the data with xor.
Perhaps this would create less of a chance of strings appearing
constant? Although wouldn't this be similar to storing a certain 8-bit
xor pattern, and then applying it to every 8 bits in the binary
string?
----------------------------------------------------------------------
That's what search engines were invented for.
If you get stuck, look for the bit about 'bit stuffing'.
MPEG has bit stuffing too, IIRC, but HDLC came first.
MFM hard disks did too, I'm sure. It's an ancient concept.
Phil, I did search for HDLC and using wiki I found it was a "bit-
oriented synchronous data link layer protocol", which seems totally
unrelated to this, hence me asking, just in case the term applied to
something else, more in line with this question. However, I fail to
understand how well this can work. For example:
01111110
cannot have a run of 6 1's. So we insert a 0 after the fifth 1:
011111010
Then when it reaches the other end (i.e. the decryption in my case) if
there is a run of five ones we remove the 0 to get the original data:
01111110
BUT, what I'm struggling to understand is, if we have this as an
input:
01111101
Then encrypting it (for this stage) would be left as it is since there
is no run of more than 5 1's, but decrypting it would give:
0111111
which is clearly not the same as the input. Perhaps you could
enlighten me? Thanks for your time. :)
----------------------------------------------------------------------
No, it still doesn't answer the basic questions. What is the need for
what you want to do? Is it encryption? Compression? Tell us *why*
you want the above behavior, how it will be used, etc. and we can
offer much more helpful answers.
Hi Jim,
I'm sorry it still didn't help, but in my defense you didn't ask those
questions, so I assumed you didn't understand what I wanted to do
rather than why I wanted to do it. :)
I'm using it for an encryption algorithm I'm writing, but the reason
I'm asking it in the compression newsgroup rather than an encryption
one is because as far as I'm aware, for compression it is much better
to get input that appears very constant; so as you have wonderful
ideas on getting the data to be constant, I'm guessing as a by-product
you'd have wonderful ideas on making it look fairly random.
----------------------------------------------------------------------
It seems that bit-stuffing could be the way forward, but as I
mentioned in the reply to Phil, what to do when the decryption has an
input that may not require a bit removed, but the algorithm remove it
anyway? Thanks everybody. :)
Nick.
.
- Follow-Ups:
- Re: Preventing large runs of identical bits.
- From: Phil Carmody
- Re: Preventing large runs of identical bits.
- From: Willem
- Re: Preventing large runs of identical bits.
- References:
- Preventing large runs of identical bits.
- From: NickHolby
- Re: Preventing large runs of identical bits.
- From: Jim Leonard
- Re: Preventing large runs of identical bits.
- From: NickHolby
- Re: Preventing large runs of identical bits.
- From: Jim Leonard
- Re: Preventing large runs of identical bits.
- From: Mark Adler
- Preventing large runs of identical bits.
- Prev by Date: Re: Arithmetic Compression
- Next by Date: Re: Preventing large runs of identical bits.
- Previous by thread: Re: Preventing large runs of identical bits.
- Next by thread: Re: Preventing large runs of identical bits.
- Index(es):
Relevant Pages
|