@Test void sha2_512_256() { String horseSha2 = "6d64886cd066b81cf2dcf16ae70e97017d35f2f4ab73c5c5810aaa9ab573dab3"; String cowSha2 = "7d26bad15e2f266cb4cbe9b1913978cb8a8bd08d92ee157b6be87c92dfce2d3e"; Bytes resultHorse = Hash.sha2_512_256(Bytes.wrap("horse".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(horseSha2), resultHorse); byte[] resultHorse2 = Hash.sha2_512_256("horse".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(horseSha2).toArray(), resultHorse2); Bytes resultCow = Hash.sha2_512_256(Bytes.wrap("cow".getBytes(UTF_8))); assertEquals(Bytes.fromHexString(cowSha2), resultCow); byte[] resultCow2 = Hash.sha2_512_256("cow".getBytes(UTF_8)); assertArrayEquals(Bytes.fromHexString(cowSha2).toArray(), resultCow2); }
public static byte[] sha2_512_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_512_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } }
Hash { public static byte[] sha2_512_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_512_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } }
Hash { public static byte[] sha2_512_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_512_256); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("Algorithm should be available but was not", e); } } private  Hash(); }
Hash { public static byte[] sha2_512_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_512_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[] sha2_512_256(byte[] input) { try { return digestUsingAlgorithm(input, SHA2_512_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);  }