@Test public void shaHashInput_withNullInput_returnsNull() { assertNull(StripeTextUtils.shaHashInput(" ")); }
@Nullable static String shaHashInput(@Nullable String toHash) { if (StripeTextUtils.isBlank(toHash)) { return null; } String hash; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] bytes = toHash.getBytes("UTF-8"); digest.update(bytes, 0, bytes.length); bytes = digest.digest(); hash = bytesToHex(bytes); } catch(NoSuchAlgorithmException noSuchAlgorithm) { return null; } catch (UnsupportedEncodingException unsupportedCoding) { return null; } return hash; }
StripeTextUtils { @Nullable static String shaHashInput(@Nullable String toHash) { if (StripeTextUtils.isBlank(toHash)) { return null; } String hash; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] bytes = toHash.getBytes("UTF-8"); digest.update(bytes, 0, bytes.length); bytes = digest.digest(); hash = bytesToHex(bytes); } catch(NoSuchAlgorithmException noSuchAlgorithm) { return null; } catch (UnsupportedEncodingException unsupportedCoding) { return null; } return hash; } }
StripeTextUtils { @Nullable static String shaHashInput(@Nullable String toHash) { if (StripeTextUtils.isBlank(toHash)) { return null; } String hash; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] bytes = toHash.getBytes("UTF-8"); digest.update(bytes, 0, bytes.length); bytes = digest.digest(); hash = bytesToHex(bytes); } catch(NoSuchAlgorithmException noSuchAlgorithm) { return null; } catch (UnsupportedEncodingException unsupportedCoding) { return null; } return hash; }  }
StripeTextUtils { @Nullable static String shaHashInput(@Nullable String toHash) { if (StripeTextUtils.isBlank(toHash)) { return null; } String hash; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] bytes = toHash.getBytes("UTF-8"); digest.update(bytes, 0, bytes.length); bytes = digest.digest(); hash = bytesToHex(bytes); } catch(NoSuchAlgorithmException noSuchAlgorithm) { return null; } catch (UnsupportedEncodingException unsupportedCoding) { return null; } return hash; }  @Nullable static String nullIfBlank(@Nullable String value); static boolean isBlank(@Nullable String value); @Nullable static String removeSpacesAndHyphens(@Nullable String cardNumberWithSpaces); }
StripeTextUtils { @Nullable static String shaHashInput(@Nullable String toHash) { if (StripeTextUtils.isBlank(toHash)) { return null; } String hash; try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] bytes = toHash.getBytes("UTF-8"); digest.update(bytes, 0, bytes.length); bytes = digest.digest(); hash = bytesToHex(bytes); } catch(NoSuchAlgorithmException noSuchAlgorithm) { return null; } catch (UnsupportedEncodingException unsupportedCoding) { return null; } return hash; }  @Nullable static String nullIfBlank(@Nullable String value); static boolean isBlank(@Nullable String value); @Nullable static String removeSpacesAndHyphens(@Nullable String cardNumberWithSpaces);  }