MD5Util工具类 package cn.itsource.shiro.util; import org.apache.shiro.crypto.hash.SimpleHash; public class MD5Util { public static final String SALT = "itsource"; /** * 加密 * @param source * @return */ public static String encrypt(String source){ SimpleHash simpleHash = new SimpleHash("MD5",source,SALT,10); return simpleHash.toString(); } public static void main(String[] args) { System.out.println(encrypt("1")); } } 2)没有的员工添加是加密保存 EmployeeController中 @Override public AjaxResult addOrUpdate(Employee employee) { if (employee.getId()==null){ employee.setPassword(MD5Util.encrypt(employee.getPassword())); employeeService.add(employee); }else{ employeeService.update(employee); } return AjaxResult.me(); }