@Override public String encode(final String password) { if (password == null) { return null; } if (StringUtils.isBlank(this.encodingAlgorithm)) { LOGGER.warn("No encoding algorithm is defined. Password cannot be encoded; Returning null"); return null; } try { final MessageDigest messageDigest = MessageDigest.getInstance(this.encodingAlgorithm); final String encodingCharToUse = StringUtils.isNotBlank(this.characterEncoding) ? this.characterEncoding : Charset.defaultCharset().name(); LOGGER.warn("Using {} as the character encoding algorithm to update the digest", encodingCharToUse); messageDigest.update(password.getBytes(encodingCharToUse)); final byte[] digest = messageDigest.digest(); return getFormattedText(digest); } catch (final NoSuchAlgorithmException e) { throw new SecurityException(e); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } }