public String encryptPassword(String password) { try { return Base64.encodeBase64String(hash(password)); } catch (NoSuchAlgorithmException ex) { return Exceptions.chuck(ex); } }
public boolean checkPassword(String unhashed, String hashed) { try { byte[] bytes = hash(unhashed); byte[] check = Base64.decodeBase64(hashed); return Arrays.equals(bytes, check); } catch (NoSuchAlgorithmException ex) { return Exceptions.chuck(ex); } }