# Triangle strip encoding

*Thu 22 June 2023*

*Tagged: steganography*

Triangle Strip Encoding is a method of encoding an arbitrary bitstream as a strip of triangles. I made it because I wanted an abstract-looking triangle pattern for a ring, but I wanted the triangles to mean something.

If you want to try encoding some strings, you can try my Triangle Strip Encoding tool. I did not make a decoding tool, so you'll have to do that on your own.

Here's the ring I made:

And the pattern on it:

## How it works

First, turn your data into a bitstream any way you like. I simply concatenated ASCII codes.

`0100101001010011`

Now prepare a grid with uniformly-spaced vertical and horizontal lines. You need as many vertical lines as you have bits to encode, and you need 4 horizontal lines.

Now plot your data on the grid, using the top 2 lines for even-indexed bits and the bottom 2 lines for odd-indexed bits, and draw lines connecting all the points:

Now draw lines to connect all the even-indexed points:

And finally draw lines to connect the odd-indexed points:

Lose the grid and you have your abstract-looking triangle pattern:

## Ambiguity

My ring encodes `0100101001010011` which is ASCII for "JS".

But a ring has no natural "up" orientation, so there are actually 2 possible ways to decode it.
One way gets you the "JS", and the other gets `0x35 0xad`, which is a digit "5" followed by a non-ASCII-code.

In general, if you get it the wrong way up, then your bitstream is reversed and inverted. It might be fun to find English words that give other valid English words when you reverse and invert their bits.

## Further expansion

You can encode your data in some base other than binary, and use more horizontal lines.
For base-n, you need ** 2n** horizontal lines. (It would actually be possible
to use a different base to encode the even numbers vs the odd numbers, see my post on
chess steganography for
an example).

Using a larger base might give you more interesting-looking triangles, and it would definitely give you shorter sequences, at the cost of making the decoding harder to eyeball in the absence of the grid.

Also, you don't need to put the values in any particular order, and the order of the values for the top line and bottom line do not need to match. For example:

Finally, you could run several different strips horizontally, and then connect the triangles
between them, to make a triangle *mesh* that encodes your data:

*If you like my blog, please consider subscribing to the RSS feed or the mailing list:*