private String encode(CharSequence rawPassword, byte[] salt) { MessageDigest sha; try { sha = MessageDigest.getInstance("SHA"); sha.update(Utf8.encode(rawPassword)); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException("No SHA implementation available!"); } if (salt != null) { sha.update(salt); } byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt); String prefix; if (salt == null || salt.length == 0) { prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX; } else { prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX; } return prefix + Utf8.decode(Base64.getEncoder().encode(hash)); }
private String encode(CharSequence rawPassword, byte[] salt) { MessageDigest sha; try { sha = MessageDigest.getInstance("SHA"); sha.update(Utf8.encode(rawPassword)); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException("No SHA implementation available!"); } if (salt != null) { sha.update(salt); } byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt); String prefix; if (salt == null || salt.length == 0) { prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX; } else { prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX; } return prefix + Utf8.decode(Base64.getEncoder().encode(hash)); }
private String encode(CharSequence rawPassword, byte[] salt) { MessageDigest sha; try { sha = MessageDigest.getInstance("SHA"); sha.update(Utf8.encode(rawPassword)); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException("No SHA implementation available!"); } if (salt != null) { sha.update(salt); } byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt); String prefix; if (salt == null || salt.length == 0) { prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX; } else { prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX; } return prefix + Utf8.decode(Base64.getEncoder().encode(hash)); }
private String encode(CharSequence rawPassword, byte[] salt) { MessageDigest sha; try { sha = MessageDigest.getInstance("SHA"); sha.update(Utf8.encode(rawPassword)); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException("No SHA implementation available!"); } if (salt != null) { sha.update(salt); } byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt); String prefix; if (salt == null || salt.length == 0) { prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX; } else { prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX; } return prefix + Utf8.decode(Base64.getEncoder().encode(hash)); }
private String encode(CharSequence rawPassword, byte[] salt) { MessageDigest sha; try { sha = MessageDigest.getInstance("SHA"); sha.update(Utf8.encode(rawPassword)); } catch (java.security.NoSuchAlgorithmException e) { throw new IllegalStateException("No SHA implementation available!"); } if (salt != null) { sha.update(salt); } byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt); String prefix; if (salt == null || salt.length == 0) { prefix = forceLowerCasePrefix ? SHA_PREFIX_LC : SHA_PREFIX; } else { prefix = forceLowerCasePrefix ? SSHA_PREFIX_LC : SSHA_PREFIX; } return prefix + Utf8.decode(Base64.getEncoder().encode(hash)); }