Compare commits
1 commit
ce70e4affe
...
3877b8f466
Author | SHA1 | Date | |
---|---|---|---|
3877b8f466 |
2 changed files with 5 additions and 3 deletions
|
@ -15,6 +15,8 @@ import jakarta.persistence.*;
|
|||
@Entity
|
||||
@Table(name = "player")
|
||||
public class Player {
|
||||
public static final int PASSWORD_SALT_BYTE_LENGTH = 16;
|
||||
public static final int PASSWORD_HASH_BYTE_LENGTH = 64;
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
@ -24,10 +26,10 @@ public class Player {
|
|||
private String username;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 64, max = 64)
|
||||
@Size(min = PASSWORD_HASH_BYTE_LENGTH, max = PASSWORD_HASH_BYTE_LENGTH)
|
||||
private byte[] passwordHash;
|
||||
|
||||
@NotNull
|
||||
@Size(min = 16, max = 16)
|
||||
@Size(min = PASSWORD_SALT_BYTE_LENGTH, max = PASSWORD_SALT_BYTE_LENGTH)
|
||||
private byte[] passwordSalt;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class PlayerService {
|
|||
}
|
||||
|
||||
public void setPassword(Player player, String password) throws NoSuchAlgorithmException {
|
||||
byte[] salt = new byte[16];
|
||||
byte[] salt = new byte[Player.PASSWORD_SALT_BYTE_LENGTH];
|
||||
this.random.nextBytes(salt);
|
||||
|
||||
byte[] passwordHash = hashPassword(
|
||||
|
|
Loading…
Add table
Reference in a new issue