MessageDigest
only works with bytes. It doesn't even accept String
s. Just bytes.
These are the available update methods. You can see that all four of them only deal with bytes:
void update?(byte input);
void update?(byte[] input);
void update?(byte[] input, int offset, int len);
void update?(ByteBuffer input);
It's up to you to serialize objects into bytes using the procedure of your choice. MessageDigest
doesn't handle it for you, nor does it have any convenience methods to assist in the process. It doesn't deal with anything except raw bytes.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…