[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

Decode this binary : ) and how did you figure out?

Posted on 2004-11-30
Medium Priority
592 Views
See this image:
http://www.thinkgeek.com/images/products/back/sdot_sf_promo_back.jpg
(from http://www.thinkgeek.com/images/products/front/sourceforge_promo.jpg)

01001001001000000111001101110000011
00101011011100111010000100000001001
00001100010011000000110000001000000
11000010111010000100000010101000110
10000110100101101110011010110100011
10110010101100101011010110010000001
10000101101110011001000010000001100
00101101100011011000010000001001001
00100000011001110110111101110100001
00000011101110110000101110011001000
00011101000110100001101001011100110
01000000110110001101111011101010111
00110111100100100000011011000110100
10110110101101001011101000110010101
10010000100000011001010110010001101
00101110100011010010110111101101110
00100000011101000010110101110011011
0100001101001011100100111010000101110

Note I might raise the points (however this is your own great brain exercise), but credit will be given to one who describes his approach in detail : )

Good luck.
0
Question by:InGearX

LVL 8

Accepted Solution

AaronReams earned 204 total points
ID: 12713054
The decoded binary says...

"I spent \$100 at ThinkGeek and all I got was this lousy limited edition t-shirt."

This is based on 8 bit ascii.  I started from the end of the binary string and worked to the beginning converting as I went...  I'm sure there's a more optimal way but I was in a rush.  Enjoy!!  -Aaron

string str = "01001001001000000111001101110000011001010110111001110100001000000010010000110001001100000011000000100000011000010111010000100000010101000110100001101001011011100110101101000111011001010110010101101011001000000110000101101110011001000010000001100001011011000110110000100000010010010010000001100111011011110111010000100000011101110110000101110011001000000111010001101000011010010111001100100000011011000110111101110101011100110111100100100000011011000110100101101101011010010111010001100101011001000010000001100101011001000110100101110100011010010110111101101110001000000111010000101101011100110110100001101001011100100111010000101110";

string strMessage="";
int count=0;
string str_byte="";
for(int i=str.Length-1; i>=0; i--)
{
str_byte = str[i]+str_byte;
count++;
if(count==8)
{
int  b = System.Convert.ToInt32( str_byte, 2 );
char c = (char)b;
strMessage = c + strMessage;
str_byte="";
count = 0;
}
}
MessageBox.Show(strMessage);
0

LVL 1

Assisted Solution

artokallio earned 200 total points
ID: 12818310
Here comes a small real-mode standalone program for Intel x86-based DOS/Windows operating systems;
it comes down to 82 bytes, which might be slightly less than the solution presented earlier.
Of course it could be made even smaller by e.g. clever choice of system services, choice of opcodes and processing order,
but for a simple app that can decode any 'image file' that contains these ones and zeroes, I think it is pretty alright.
It handles redirection, so you can have it process either some file or your (terminated) keyboard input.
I tried to write it so that any old assembler would accept it. The code assumes DS=CS.

The idea is to decode eight characters represented by either ASCII '0's or '1's (all other input characters are skipped) into binary,
then to output the accumulated character (cooked) and keep repeating this until the input is exhausted.
The code utilises two DOS-level system services: read from file and write from file. This will allow to use command-line redirection.
The code is not as dense as it could be, for sake of readability and porting ease.

Tested on: DOS 6.22,Win95,Win98,Win4/SP6,Win2K/SP4,WinXP/SP1

Run using (program file 'DECODE.COM', input file 'image'):  DECODE <image

And the decoded text of course is
'I spent \$100 at ThinkGeek and all I got was this lousy limited edition t-shirt.'
which is conveniently 79 bytes long to fit on a single line.

DOS      EQU      21h
COUNT      EQU      si
WRITE      EQU      40h
ZERO      EQU      '0'
ONE      EQU      '1'

start:      jmp decode

Input            DB 0            ;for stdin
Output      DB 0            ;for stdout

decode:
mov [Output],0      ;the accumulated byte
mov COUNT,8      ;bit counter
next:
mov bx,0      ;stdin
mov cx,1
lea dx,Input      ;into ds:dx tiny model, ds=cs
int DOS            ;read next input character
cmp ax,0            ;none?
jz quit

;accept only '0' and '1'
cmp [Input],ZERO
jz got0
cmp [Input],ONE
jz got1
jmp next

got0:
shl [Output],1      ;punch the zero
jmp isdone
got1:
shl [Output],1
or [Output],1      ;punch the one

isdone:
dec COUNT
jnz next      ;loop until eight bits have been collected

mov ah,WRITE
mov bx,1      ;stdout
mov cx,1
lea dx,Output
int DOS            ;show the accumulated character

jmp decode      ;keep on truckin'

quit:
ret

/R2

PS. A curious fact about the 'image': when stored into a file with the exact layout presented in the question and
using DOS-type line termination (CR+LF) for each line except the last, the file length is 666 bytes. Should this mean anything? ;-)

/Ditto

0

LVL 23

Expert Comment

ID: 13527520
How do you decode it in visual basic just outta curiousty ?
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month18 days, 15 hours left to enroll