What is the size of char []?

I am making a hash algorithm, the message block is 512 bit. In C/C++I can store in char[64], but Java chartakes 2 bytes.

Question: 512 bits of information: char[32]or char[64]?

+4
source share
3 answers

Char is 16 bits in Java. Therefore, char [32] should be sufficient for 512 bits. I think using byte [64] is better, although due to the fact that everyone knows that byte is 8 bits and char [32] makes the code more difficult to read. Also, you do not store characters other than bits.

+6
source

From the documentation :

char. char - 16- . '\ u0000' ( 0) '\ uffff' ( 65 535 ).

, 512 , 32.

+1

Why use char[]?

The hash value consists of byte, so usage is the logical choice byte[64].

The data type is charintended to be used as a symbol, not as a number.

+1
source

All Articles