/** * Encodes/obfuscates a password. Although this does not prevent actual * hacking of password, it does remove the obvious threats of having * passwords stored as clear text. * * @param password * @return a String containing the encoded password */ public static String encodePassword(final String password) { if (password == null) { return null; } return encodePassword(password.toCharArray()); }
/** * It encodes/obfuscates a password and adds a human readable prefix that clarifies it. * * @param passwordInPlainText * @return a String containing the encoded password */ public static String encodePasswordWithPrefix(final String passwordInPlainText) { if (hasPrefix(passwordInPlainText)) { return passwordInPlainText; } return PREFIX + encodePassword(passwordInPlainText); }