public static String gen(User user) { Token token = new Token(); token.setTid(user.getId()); // token.setDvhs(teacher.getLastDeviceId().hashCode()); token.setThs(getHashCode(user)); String str = JsonUtil.obj2Json(token); return CipherUtil.encode(str, PropertyUtil.getProperty("key")); }
private static int getHashCode(User user) { String str = ""; if (StringUtils.equals(user.getLoginType(), "1")) { str = user.getPhoneNumber() + "|" + user.getPassword() + "|" + user.getDeviceId(); } else { str = user.getPhoneNumber() + "|" + user.getPassword() + "|" + user.getIp(); } return str.hashCode(); }