doubledee Posted January 31, 2012 Share Posted January 31, 2012 What is the relationship between BITS, BYTES, and CHARACTERS?? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/ Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 In what context? There are 8 bits in 1 byte. Most characters are 1 byte, though I think that depends on how it is stored in memory. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312820 Share on other sites More sharing options...
doubledee Posted January 31, 2012 Author Share Posted January 31, 2012 In what context? There are 8 bits in 1 byte. Most characters are 1 byte, though I think that depends on how it is stored in memory. Darkfreaks said a SHA256 was 64 Characters... 256 Bits would equal 32 Bytes and thus 32 Characters, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312822 Share on other sites More sharing options...
darkfreaks Posted January 31, 2012 Share Posted January 31, 2012 SHA256 is always 256 bits long, equivalent to 32 bytes, or 64 bytes in an hexadecimal string Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312825 Share on other sites More sharing options...
doubledee Posted January 31, 2012 Author Share Posted January 31, 2012 SHA256 is always 256 bits long, equivalent to 32 bytes, or 64 bytes in an hexadecimal string What happened to the 8 Bits = 1 Byte = 1 Character?? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312836 Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2012 Share Posted January 31, 2012 Each hex digit represents 4 bits, or a "nibble", since its possible values are 0-F (0-15), represented in binary as 0000 - 1111. Therefore 64 hex digits is 256 bits. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312838 Share on other sites More sharing options...
doubledee Posted January 31, 2012 Author Share Posted January 31, 2012 Each hex digit represents 4 bits, or a "nibble", since its possible values are 0-F (0-15), represented in binary as 0000 - 1111. Therefore 64 hex digits is 256 bits. And a Character is 8 Bits or 1 Byte because it goes beyond 0-F, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312857 Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 No, it takes two hexadecimal digits (since each digit is 4 bits) to represent 1 byte. Like the letter "a" in hexadecimal is "61". So therefore you should be able to see why it would take 64 hexadecimal digits to represent 32 characters (bytes). Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312860 Share on other sites More sharing options...
doubledee Posted January 31, 2012 Author Share Posted January 31, 2012 No, it takes two hexadecimal digits (since each digit is 4 bits) to represent 1 byte. Like the letter "a" in hexadecimal is "61". So therefore you should be able to see why it would take 64 hexadecimal digits to represent 32 characters (bytes). Right, but this should also be true... And a Character is 8 Bits or 1 Byte because it goes beyond 0-F, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312863 Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 I'm not sure what you mean by "goes beyond 0-F". Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312864 Share on other sites More sharing options...
doubledee Posted January 31, 2012 Author Share Posted January 31, 2012 Each hex digit represents 4 bits, or a "nibble", since its possible values are 0-F (0-15), represented in binary as 0000 - 1111. Therefore 64 hex digits is 256 bits. A "Character" is like anything in the ASCII table, and if 4 bits holds 0-F, then to hold the entire ASCII table, you must need twice as much. So an "ASCII Character" would be 8 Bits or 1 Byte, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312865 Share on other sites More sharing options...
scootstah Posted January 31, 2012 Share Posted January 31, 2012 Yes, which would be represented in hexadecimal by two hexadecimal digits. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312867 Share on other sites More sharing options...
laffin Posted January 31, 2012 Share Posted January 31, 2012 yer missing the point A character can be 2 bytes as well this all depends on yer character representation (UTF8 for example) 1 byte - 0-255 dec 00-FF hex (an ascii character) 1 bit - 0-1 - base 2 number system 1 nibble - 0-15 base 16 numbering system (0-F hex) 1 byte = 2 nibbles = 0-255 (00-FF hex) [quote]Darkfreaks said a SHA256 was 64 Characters... 256 Bits would equal 32 Bytes and thus 32 Characters, right? 32 bytes in length, correct. However to maintain some sanity this sequence is returned in HEX notation so only using characters 0-9 and A-F (2 characters to represent 1 hex byte). Thus the 64 bytes that dark was referring to. This is done to keep some sanity between various systems/languages. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1312896 Share on other sites More sharing options...
doubledee Posted February 1, 2012 Author Share Posted February 1, 2012 yer missing the point A character can be 2 bytes as well this all depends on yer character representation (UTF8 for example) 1 byte - 0-255 dec 00-FF hex (an ascii character) 1 bit - 0-1 - base 2 number system 1 nibble - 0-15 base 16 numbering system (0-F hex) 1 byte = 2 nibbles = 0-255 (00-FF hex) [quote]Darkfreaks said a SHA256 was 64 Characters... 256 Bits would equal 32 Bytes and thus 32 Characters, right? 32 bytes in length, correct. However to maintain some sanity this sequence is returned in HEX notation so only using characters 0-9 and A-F (2 characters to represent 1 hex byte). Thus the 64 bytes that dark was referring to. This is done to keep some sanity between various systems/languages. Sorry, I'm not getting this because people keep swapping BITS and BYTES and CHARACTERS interchangeably?! Let's try again... If I am using a SHA256 Hash, then (I believe) that is... - 256 Bits - 32 Bytes (8 Bits in 1 Byte, 1 Hexadecimal Character in 1 Nibble, 2 Nibbles in 1 Byte, 2 Hexadecimal Characters in 1 Byte) - 64 Hexadecimal Characters (e.g. CHAR(64)) Can we all agree on that? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1313425 Share on other sites More sharing options...
scootstah Posted February 1, 2012 Share Posted February 1, 2012 Sorry, I'm not getting this because people keep swapping BITS and BYTES and CHARACTERS interchangeably?! Let's try again... If I am using a SHA256 Hash, then (I believe) that is... - 256 Bits - 32 Bytes (8 Bits in 1 Byte, 1 Hexadecimal Character in 1 Nibble, 2 Nibbles in 1 Byte, 2 Hexadecimal Characters in 1 Byte) - 64 Hexadecimal Characters (e.g. CHAR(64)) Can we all agree on that? Debbie Yes, depending on the character encoding. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1313430 Share on other sites More sharing options...
kicken Posted February 1, 2012 Share Posted February 1, 2012 Sorry, I'm not getting this because people keep swapping BITS and BYTES and CHARACTERS interchangeably?! As mentioned: A BIT = a single on/off switch, 1/0 A BYTE = 8 BITs A CHARACTER = usually a single printable glyph such as 'a' or 'µ' or 'ﺶ' Now, the relationship between a CHARACTER and a BYTE depends on the charset/encoding being used. When your talking standard ascii this is a simple 1:1 relationship. For years this was the case, and as a result a lot of people/places/texts will consider a character and a byte to be equivalent (for instance in the C programming language the 'char' data type is one-byte). In the modern international age though this assumed 1:1 relation is not longer true. encoding such as utf-8 can use anywhere from 1 to 6 bytes to store a single character. When binary data needs to be represented in a printable format there are two common methods: base64 or hex notation. When you deal with hex notation, which is common for short values such as hashes, you have to use 2 characters for each byte. The first character represent the first four high-order bits, and the second character represents last-four low order bits: For instance, the byte value 173 is represented as these 8 bits: 10101101, and in hex AD, which breaks down like this: 10101101 = AD Since hex uses standard ascii characters '0'-'9', 'a'-'f' the relationship of characters-to-bytes is 1:1 so you only need one byte per character, but you end up with twice as many characters in the hex string because you need two characters for each original byte. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1313436 Share on other sites More sharing options...
Doug G Posted February 2, 2012 Share Posted February 2, 2012 Throw in serial communication and baud for fun where you may need 10 or 11 bits per ascii character. The different possible bit count per character is why phone modem speeds were listed in baud, not bits/sec The only truly standard difinition is a bit, I started with an octal-based computer where each byte (yes some called octal digits bytes) was 3 bits. Quote Link to comment https://forums.phpfreaks.com/topic/256088-bits-bytes-and-characters/#findComment-1313526 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.