@Test public void testGetMD5Hash() throws Exception { HashHelper hashHelper = new MD5HashHelperImpl(); assertEquals("Get unexpected hash", "5f4dcc3b5aa765d61d8327deb882cf99", hashHelper.getHash("password")); assertEquals("Get unexpected hash", "fcea920f7412b5da7be0cf42b8c93759", hashHelper.getHash("1234567")); }
@Override @Cacheable(value = "passwordHashHelper-hash") public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] md5hash; final String saltedPassword = StringUtils.isNotBlank(salt) ? password.concat(salt) : password; digest.update(saltedPassword.getBytes("utf-8"), 0, saltedPassword.length()); md5hash = digest.digest(); return convertToHex(md5hash); }
MD5HashHelperImpl implements HashHelper, PasswordEncoder { @Override @Cacheable(value = "passwordHashHelper-hash") public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] md5hash; final String saltedPassword = StringUtils.isNotBlank(salt) ? password.concat(salt) : password; digest.update(saltedPassword.getBytes("utf-8"), 0, saltedPassword.length()); md5hash = digest.digest(); return convertToHex(md5hash); } }
MD5HashHelperImpl implements HashHelper, PasswordEncoder { @Override @Cacheable(value = "passwordHashHelper-hash") public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] md5hash; final String saltedPassword = StringUtils.isNotBlank(salt) ? password.concat(salt) : password; digest.update(saltedPassword.getBytes("utf-8"), 0, saltedPassword.length()); md5hash = digest.digest(); return convertToHex(md5hash); }  }
MD5HashHelperImpl implements HashHelper, PasswordEncoder { @Override @Cacheable(value = "passwordHashHelper-hash") public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] md5hash; final String saltedPassword = StringUtils.isNotBlank(salt) ? password.concat(salt) : password; digest.update(saltedPassword.getBytes("utf-8"), 0, saltedPassword.length()); md5hash = digest.digest(); return convertToHex(md5hash); }  void setSalt(final String salt); void setConfig(final Resource config); @Override @Cacheable(value = "passwordHashHelper-hash") String getHash(final String password); @Override String encode(final CharSequence rawPass); @Override boolean matches(final CharSequence rawPass, final String encPass); HashHelper getSelf(); }
MD5HashHelperImpl implements HashHelper, PasswordEncoder { @Override @Cacheable(value = "passwordHashHelper-hash") public String getHash(final String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { final MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] md5hash; final String saltedPassword = StringUtils.isNotBlank(salt) ? password.concat(salt) : password; digest.update(saltedPassword.getBytes("utf-8"), 0, saltedPassword.length()); md5hash = digest.digest(); return convertToHex(md5hash); }  void setSalt(final String salt); void setConfig(final Resource config); @Override @Cacheable(value = "passwordHashHelper-hash") String getHash(final String password); @Override String encode(final CharSequence rawPass); @Override boolean matches(final CharSequence rawPass, final String encPass); HashHelper getSelf();  }