@Test public void test() { User user = this.userservice.findUser("201158080111"); System.out.println(user.getPassword()); byte[] test = gen(user.getSalt(), "201158080111"); String cp = Encodes.encodeHex(test); System.out.println(cp); System.out.println(this.userservice.login(user, "201158080111")); }
public byte[] gen(String salt, String password) { try { MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.reset(); digest.update(Encodes.decodeHex(salt)); byte[] hashed = digest.digest(password.getBytes()); for (int i = 0; i < 1023; i++) { digest.reset(); hashed = digest.digest(hashed); } return hashed; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return null; }