@Test void sha3_256() { String horseSha3 = "d8137088d21c7c0d69107cd51d1c32440a57aa5c59f73ed7310522ea491000ac"; String cowSha3 = "fba26f1556b8c7b473d01e3eae218318f752e808407794fc0b6490988a33a82d"; Bytes resultHorse = Hash.sha3_256(Bytes.wrap("horse".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(horseSha3), resultHorse); byte[] resultHorse2 = Hash.sha3_256("horse".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(horseSha3).toArray(), resultHorse2); Bytes resultCow = Hash.sha3_256(Bytes.wrap("cow".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(cowSha3), resultCow); byte[] resultCow2 = Hash.sha3_256("cow".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(cowSha3).toArray(), resultCow2); }
public static byte[] sha3_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA3_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } }
Hash { public static byte[] sha3_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA3_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } }
Hash { public static byte[] sha3_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA3_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } private  Hash(); }
Hash { public static byte[] sha3_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA3_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[] sha3_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA3_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);  }