1

How to convert String from input text to md5? I have no clue.

This is part of my .jsp

<tr> <td><spring:message code="password" text="default text" /></td> <td>:</td> <td><input type="password" name="password" required></td> 

and this is my controller

@RequestMapping(value="/admin/addUser.html", method=RequestMethod.POST) public ModelAndView createUserAdmin(@ModelAttribute UserAdmin useradmin, ModelMap model)throws Exception { userService.save(useradmin); model.addAttribute("successAdd", "true"); return listUserAdmin(model); } 

Thanks for any help :)

2

1 Answer 1

0

Use this method pass string as parameter it will return MD5 as return string. Store that string in database.

public static String getMD5(String data) throws NoSuchAlgorithmException { MessageDigest messageDigest=MessageDigest.getInstance("MD5"); messageDigest.update(data.getBytes()); byte[] digest=messageDigest.digest(); StringBuffer sb = new StringBuffer(); for (byte b : digest) { sb.append(Integer.toHexString((int) (b & 0xff))); } return sb.toString(); } 
Sign up to request clarification or add additional context in comments.

2 Comments

whoaah..your answer give me some clue and the problem is solved now... big thanks, dude :)
welcome. I like to help :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.