### Question:
Hash { public static byte[] sha2_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_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);  }### Answer:
@Test void sha2_256() { String horseSha2 = "fd62862b6dc213bee77c2badd6311528253c6cb3107e03c16051aa15584eca1c"; String cowSha2 = "beb134754910a4b4790c69ab17d3975221f4c534b70c8d6e82b30c165e8c0c09"; Bytes resultHorse = Hash.sha2_256(Bytes.wrap("horse".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(horseSha2), resultHorse); byte[] resultHorse2 = Hash.sha2_256("horse".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(horseSha2).toArray(), resultHorse2); Bytes resultCow = Hash.sha2_256(Bytes.wrap("cow".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(cowSha2), resultCow); byte[] resultCow2 = Hash.sha2_256("cow".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(cowSha2).toArray(), resultCow2); }