Jump to content


Photo
- - - - -

binary <==> ascii


  • Please log in to reply
8 replies to this topic

#1 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,075 posts
  • Country:
  • Gender:Male

Posted 28 September 2002 - 01:24 AM

This is a spillover thread from another topic that wandered. I thought it would be good for the nubie forum. A lot of people know how to do this, but they are not exactly correct. They are close enough to understand, but this may be a little more clear. I may clean all of this up into a nubie article at some point (not for publish, but just for this site).

Firstly, lets rehash a little bit of basic computer background. Everyone learned in their first computer class that there are 8 bits in a byte. We also learned that there is 1 byte per character. The bits that make up that character are a combination of ZEROES and ONES. The computer interprets these 1s and 0s into a readable human language standard as defined by ANSI. This format is called ASCII. The 1s and 0s are called BINARY.

so...

Since you have 8 BITS to define the character you want, you use a simple mathematical algorithm to figure out the values for the characters you want. You can do this in your head, but it can be time consuming. Lets start with an easy example.

the first logical binary combination is 00000000 (EIGHT ZEROES). this is the starting point and is called a "NUL" or null value. It actually literally means nothing. Think of it as opening your mouth, but nothing comes out. The next combination, would be 00000001. This is logically the next sequential number in the sequence. This is where a lot of people make their first mistake.

To be thorough, you should never drop leading ZEROES!!! Mathematically, 1=01=0001=00000001 ! Leading zeroes are ignored! NOT IN BINARY!!! It takes ALL EIGHT bits to define each byte. There is no other way to know the start and stop point of the byte other than length! Which is another thing that some people don't understand. There are NO SPACES between letters, words, or anything in binary. It is location dependant.

But lets keep the examples simple right now.

I mentioned earlier that the next sequential number in binary would be 00000001. Most people assume this to be the letter "A". I also explained that some people drop the leading ZEROES, and just think that 1=A=00000001. The next number in sequence is 00000010 (sometimes written as 10) since the binary system only uses 1 and 0. The third number in sequence is 00000011 (sometimes written as 11) and so on, and so on. They are commonly assumed to be B and C, and so on. By following this pattern, you can cover all 26 letters by only needing 5 of the 8 significant digits ending with Z as 00011010 (or 11010, dropping the leading zeroes).

This is "almost" correct.

You NEVER DROP LEADING ZEROES!!! IN BINARY, ALL DIGITS ARE SIGNIFICANT DIGITS!!! Here is why.

Since I explained that you only need 5 to define the letters, and that all 8 are needed for the BYTE makeup, that leaves 3 digits unused, right? These digits are used to further breakdown ASCII characters. These are characters like the playing card faces(00000011,00000100,00000101,00000110 ), and stuff like that. Some other non-alphanumeric characters begin with "001" such as "00100000" which is the BLANKSPACE character (much different then a NUL character).

The first three digits for the standard 26 letter english alphabet (capital letters only) begin with "010" and then the 5 digit sequence as defined above. The first three digits if the lower case numbers begin with "011".

SO, that means that the capital letter "A" in binary is...

NOT "1"
NOT "00001"
NOT "00000001"

BUT IS "01000001"

And since the length is always 8 for each BYTE/CHARACTER you know that you do not need the space or any delimeter after the first BYTE, so you go right into your next letter. Note that words are seperated naturally by including the BINARY notation for a space and not actually delimiting it with a space. BINARY is always one continuous string of characters.

Now look at the message below and decode it using this method. Don't post the answer here and ruin it for everyone, just post if you understand it.

0100001001001001010011100100000101010010010110010010000001010010010101010100110001000101010100110010000001000001
0100111001000100001000000101001101001111001000000100010001001111010001010101001100100000010001000100010001010000

Now, it is late, the stuff above is probably not as clear as I had hoped, but I will clean it up another time. Bedtime for Stanky! :paw:

________
EDIT by nick84: Not sure how people feel about others editing their posts is it “allowed”? - (hope you don’t mind SD)

Anyway I just split the long binary number you have onto two lines, because otherwise when people read the page they have to keep scrolling across and back because the 1 long continuous character string does not automatically get wrapped to a new line. :)

#2 nick84

nick84

    Member

  • Agents of the Revolution
  • 1,680 posts
  • Gender:Male

Posted 28 September 2002 - 03:42 AM

0100001001001001010011100100000101010010010110010010000001010010010101010100110001000101010100110010000001000001
0100111001000100001000000101001101001111001000000100010001001111010001010101001100100000010001000100010001010000

%49%6E%64%65%65%64%2C%20%42%69%6E%61%72%79%20%44%44%50%20%64%6F%20%72%75%6C%65%2E%20%20%42%55%54%20%48%45%58%20%41%4C%53%4F%20%52%55%4C%45%53%20%4D%55%43%48%20%42%45%54%54%45%52%20%54%48%41%4E%20%42%49%4E%41%52%59%20%3A%29

:borg:

#3 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,075 posts
  • Country:
  • Gender:Male

Posted 29 September 2002 - 01:39 AM

Generally editing other posts is not a good idea (Free speech and all), but I gave you moderator power for a reason. I trust you with it! I don't mind you editing that post from me.

%49%6E%64%65%65%64%2C%20%42%69%6E%61%72%79%20%44%44%50%20%64%6F%20%72%75%6C%65%2E%20%20%42%55%54%20%48%45%58%20%41%4C%53%4F%20%52%55%4C%45%53%20%4D%55%43%48%20%42%45%54%54%45%52%20%54%48%41%4E%20%42%49%4E%41%52%59%20%3A%29



1) You started with mixed case, then stopped.

2) The delimiters that you use (%) show that you are a child of the WEB. Numbering systems do not need delimiters.

3) Binary is machine level while ascii is human level. HEX is simply a bastard child that falls in between the two. ;)

#4 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,075 posts
  • Country:
  • Gender:Male

Posted 29 September 2002 - 01:55 AM

This isn't the greatest tool for large conversions (like translating these conversations) but it is great for short messages. I have had it for a long time and recently, due to renewed interest, downloaded the latest version from http://ourworld.comp...pages/r_harvey/ .

#5 nick84

nick84

    Member

  • Agents of the Revolution
  • 1,680 posts
  • Gender:Male

Posted 29 September 2002 - 03:33 AM

The delimiters that you use (%) show that you are a child of the WEB.  Numbering systems do not need delimiters.

Child of the web lol, I don’t know about that, im more a child of understanding hex, binary etc.

Anyway’s, its not my fault the %’s are there, the automatic conversion utitity I used ( http://www.paradigm....x/ascii2hex.htm ) put them in :(

#6 StankDawg

StankDawg

    same old Dawg, no new tricks

  • Moderating Team
  • 8,075 posts
  • Country:
  • Gender:Male

Posted 29 September 2002 - 11:03 AM

What I mean is that if you use a symbol in your URL you need the % sign to delimit them. If you have a SPACE you will see %40 to represent the space in the URL. This is how most people know hex codes. If you are interested in the numeric theology behind them, which it seems like you are, make sure you take a "Number systems" class in college. It may be listed as "Discrete Mathematics".

You make make a numbering system with any BASE that you want. IT just so happens that BASE 16, BASE 10, Base 8, and Base 2 are the most appropriate to computer technology.

#7 nick84

nick84

    Member

  • Agents of the Revolution
  • 1,680 posts
  • Gender:Male

Posted 30 September 2002 - 12:17 PM

Thanks for clearing that up :D

#8 0ccupant

0ccupant

    DDP Fan club member

  • Members
  • 56 posts

Posted 15 December 2002 - 07:02 AM

Another fun puzzle.

Try solving it using vi while keeping keystokes to a minimium.

It's like playing a real cool version of hangman.

#9 BoBB

BoBB

    SUP3R 31337

  • Members
  • 155 posts

Posted 15 December 2002 - 08:38 PM

I solved, it wasn't hard it took me about 5 minutes. What i did was
1. Bust out my trusty notepad
2. I went ahead and converted the entire alphabet, not nearly as time consuming as i thought it was.
3. Then copied the string in increments of 8 and converted them :)
Also a very handy tool for converting/unconverting binary messages ...
#!/usr/bin/perl -w

$x = 0;

print "text to convert: ";
chomp($x = <STDIN>);

print unpack("B*","$x");
print "\n";

and to convert from binary to ascii
#!/usr/bin/perl -w

$x = 0;

print "text to convert: ";
chomp($x = <STDIN>);

print pack("B*","$x");
print "\n";
I got those from http://darkbytes.net He has a few usefull perl scripts up on his website and some good themes/background images/random cool stuff. He also has a book called Underground up there in text. I havent finished it yet but its been good so far. Check it out.




BinRev is hosted by the great people at Lunarpages!