Not sure if I understand this - Networking - bits, bytes, etc.

Discussion in 'Mac Programming' started by slooksterPSV, Aug 2, 2006.

  1. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #1
    Ok I'm not sure I understand this, though it makes sense in my mind and I don't want to get this wrong.

    If I have a key that is hexadecimal its a 16-bit's right? 0-F right?
    If I have a key that takes 5 pairs of hexadecimal bits its 10-bits right? AB CD EF GH IJ
    Now if I have a 64-bit encryption it takes the 5 pairs of hexadecimal bits right? so 2^5 = 32 bytes, so its a 32 byte word or character string is what I'm meaning. Now when it encrypts that word to a 64-bit encryption it does (in programming terms) this, it bit shifts the 32 byte word 63 places right. e.g.

    wordtwo = word << 63

    That's what makes the 64-bit encryption, correct? But it does it to each individual character, correct? But it may be in an algorithm to mix up the letters and to add a key value and mix in the key value correct?

    I need to make sure I have this down, cause it makes sense to me, but I'm not sure if its right or wrong.
     
  2. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #2
    I'm not quite sure what you're asking, but a hexadecimal number (can't say "digit") is 4 bits, e.g. F = 1111.

    A byte is represented by two hex numbers, e.g. A9 = 1010 1001.

    So five pairs of hexes is 5 bytes or 40 bits.

    On the other hand, if you're talking about characters rather than the actual hex representation of the value, each ASCII character is 8 bits, so five pairs of characters is 10 bytes or 80 bits. UTF-8 characters can be between 1 and 4 bytes, or 8-32 bits.
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    A single hexidecimal value is 4-bits (which is 0.5 bytes). This can be represented as a single character [0-9,A-F], but one should not confuse the display of the character with the value (as an ASCII character is 8 bits)

    A pair of hexidecimal values can represent 256 (0-255) values, which is a single byte (or 8 bits). So 5 pairs of hex digits = 5 bytes = 40 bits.

    A 64 bit value would require 8 bytes or 16 hex values.
     
  4. macrumors 68020

    ChrisBrightwell

    Joined:
    Apr 5, 2004
    Location:
    Huntsville, AL
    #4
    Also defined as a "nibble." Seriously.
     
  5. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    It's true. I was taught that term at school many moons ago!
     
  6. thread starter macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #6
    Perfect! thanx you guys, now its time to go post another problem in a thread
     
  7. macrumors 68000

    GeeYouEye

    Joined:
    Dec 9, 2001
    Location:
    State of Denial
    #7
    Bit-shifting a 32 bit number 63 places in either direction will result in a totally zeroed number, ie

    t = 123456;
    t = t << 63;
    printf(t);

    would print "0".
     
  8. thread starter macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #8
    Oh duh, that's right, how they explained it was perfect so yeah.
     

Share This Page