use of com.icodici.crypto.digest.Sha256 in project universa by UniversaBlockchain.
the class SymmetricKeyTest method testHashes.
@Test
public void testHashes() throws Exception {
byte[] valid = Hex.decode("ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61" + " f20015ad");
Digest d = new Sha256();
d.update('a');
d.update("bc".getBytes());
assertArrayEquals(valid, d.digest());
// And SHA512 too
valid = Hex.decode("ddaf35a193617aba cc417349ae204131 12e6fa4e89a97ea2 0a9eeee64b55d39a " + "2192992a274fc1a8 36ba3c23a3feebbd 454d4423643ce80e " + "2a9ac94fa54ca49f");
assertArrayEquals(valid, new Sha512().digest("abc"));
}
use of com.icodici.crypto.digest.Sha256 in project universa by UniversaBlockchain.
the class PublicKey method fingerprint.
@Override
public byte[] fingerprint() {
synchronized (publicKey) {
if (_fingerprint == null) {
_fingerprint = new byte[33];
_fingerprint[0] = (byte) FINGERPRINT_SHA256;
System.arraycopy(updateDigestWithKeyComponents(new Sha256()).digest(), 0, _fingerprint, 1, 32);
}
return _fingerprint;
}
}