@Test(expected = IllegalArgumentException.class) public void whenInputStringIsNullShouldThrowArgumentException() { String input = null; Sha256.hash(input); }
public static byte[] hash(String text) { if (text == null) { throw new IllegalArgumentException("Text must not be null"); } try { return hash(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException("The encoding 'UTF-8' is not supported", e); } }
Sha256 { public static byte[] hash(String text) { if (text == null) { throw new IllegalArgumentException("Text must not be null"); } try { return hash(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException("The encoding 'UTF-8' is not supported", e); } } }
Sha256 { public static byte[] hash(String text) { if (text == null) { throw new IllegalArgumentException("Text must not be null"); } try { return hash(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException("The encoding 'UTF-8' is not supported", e); } } private  Sha256(); }
Sha256 { public static byte[] hash(String text) { if (text == null) { throw new IllegalArgumentException("Text must not be null"); } try { return hash(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException("The encoding 'UTF-8' is not supported", e); } } private  Sha256(); static byte[] hash(String text); static byte[] hash(byte[] bytes); static byte[] hash(byte[] bytes, int offset, int length); }
Sha256 { public static byte[] hash(String text) { if (text == null) { throw new IllegalArgumentException("Text must not be null"); } try { return hash(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new UnsupportedOperationException("The encoding 'UTF-8' is not supported", e); } } private  Sha256(); static byte[] hash(String text); static byte[] hash(byte[] bytes); static byte[] hash(byte[] bytes, int offset, int length);  }