@Test void keccak256() { String horseKeccak256 = "c87f65ff3f271bf5dc8643484f66b200109caffe4bf98c4cb393dc35740b28c0"; String cowKeccak256 = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4"; Bytes resultHorse = Hash.keccak256(Bytes.wrap("horse".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(horseKeccak256), resultHorse); byte[] resultHorse2 = Hash.keccak256("horse".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(horseKeccak256).toArray(), resultHorse2); Bytes resultCow = Hash.keccak256(Bytes.wrap("cow".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(cowKeccak256), resultCow); byte[] resultCow2 = Hash.keccak256("cow".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(cowKeccak256).toArray(), resultCow2); }
public static byte[] keccak256(byte[] input) { try { return digestUsingAlgorithm(input, KECCAK_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } }
Hash { public static byte[] keccak256(byte[] input) { try { return digestUsingAlgorithm(input, KECCAK_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } }
Hash { public static byte[] keccak256(byte[] input) { try { return digestUsingAlgorithm(input, KECCAK_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } private  Hash(); }
Hash { public static byte[] keccak256(byte[] input) { try { return digestUsingAlgorithm(input, KECCAK_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } private  Hash(); static byte[] digestUsingAlgorithm(byte[] input, String alg); static Bytes digestUsingAlgorithm(Bytes input, String alg); static byte[] sha2_256(byte[] input); static Bytes32 sha2_256(Bytes input); static byte[] sha2_512_256(byte[] input); static Bytes32 sha2_512_256(Bytes input); static byte[] keccak256(byte[] input); static Bytes32 keccak256(Bytes input); static byte[] keccak512(byte[] input); static Bytes keccak512(Bytes input); static byte[] sha3_256(byte[] input); static Bytes32 sha3_256(Bytes input); static byte[] sha3_512(byte[] input); static Bytes sha3_512(Bytes input); }
Hash { public static byte[] keccak256(byte[] input) { try { return digestUsingAlgorithm(input, KECCAK_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } private  Hash(); static byte[] digestUsingAlgorithm(byte[] input, String alg); static Bytes digestUsingAlgorithm(Bytes input, String alg); static byte[] sha2_256(byte[] input); static Bytes32 sha2_256(Bytes input); static byte[] sha2_512_256(byte[] input); static Bytes32 sha2_512_256(Bytes input); static byte[] keccak256(byte[] input); static Bytes32 keccak256(Bytes input); static byte[] keccak512(byte[] input); static Bytes keccak512(Bytes input); static byte[] sha3_256(byte[] input); static Bytes32 sha3_256(Bytes input); static byte[] sha3_512(byte[] input); static Bytes sha3_512(Bytes input);  }