sobota, 9 maja 2009

A cryptographic hash of an empty byte array does exist. Honestly.

An hour or so spent and finally the reason found - no data. That test proves it in a way:

@Test
public void testNullDigest() throws Exception {
MessageDigest md = MessageDigest.getInstance("SHA1");
System.out.println(ArrayUtils.toString(md.digest(new byte[0])));
}

The output:

{-38,57,-93,-18,94,107,75,13,50,85,-65,-17,-107,96,24,-112,-81,-40,7,9}


Exactly the same as the one I was getting. In particular, different from the expected one (suprise). I should make some constant ;-/

Brak komentarzy:

Prześlij komentarz