Jump to content

Recommended Posts

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

 

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

 

 

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).

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

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

 

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.

 

 

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

 

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.

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.

 

 

 

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.