Spring security 비밀번호 암호화

북마크 추가

form에서 컨트롤러를 호출하면

@RequestMapping(value = "/form에서 호출한 url", method = RequestMethod.POST)

public String insertMem(HttpSession session,HttpServletRequest req, @RequestParam("img") MultipartFile file) throws IllegalStateException, IOException {

//생략

StandardPasswordEncoder encoder = new StandardPasswordEncoder();

Member member = new Member();

member.setPassword(encoder.encode((String)req.getParameter("password")));

//생략

return "redirect:main";

}

form에서 넘어온 parameter를 선언한 encoder로 인코딩하면 암호화되어 db에 저장됨

AD
관리자
2014-07-15 19:19
SHARE
댓글

org.springframework.security.crypto.password.StandardPasswordEncoder
관리자

StandardPasswordEncoder는 스프링 시큐리티에 존재하는 메소드 인가요?
개*****