@Nonnegative @Immutable public final class PasswordSalt extends Object implements IPasswordSalt
IPasswordSalt using
VerySecureRandom.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_SALT_BYTES
Default salt byte length is nothing else is specified.
|
| Constructor and Description |
|---|
PasswordSalt()
Create a new password salt with the default length of
512 and random bytes.
|
PasswordSalt(int nSaltBytes)
Constructor to create a new password salt with the provided byte count.
|
| Modifier and Type | Method and Description |
|---|---|
static PasswordSalt |
createFromStringMaybe(String sSalt)
Try to create a
PasswordSalt object from the passed string. |
boolean |
equals(Object o) |
int |
getSaltByteCount() |
byte[] |
getSaltBytes() |
String |
getSaltString() |
int |
hashCode() |
String |
toString() |
public static final int DEFAULT_SALT_BYTES
public PasswordSalt()
public PasswordSalt(@Nonnegative int nSaltBytes)
nSaltBytes - The number of salt bytes to use. Must be > 0.@Nonnegative public int getSaltByteCount()
getSaltByteCount in interface IPasswordSalt@Nonnull @Nonempty @ReturnsMutableCopy public byte[] getSaltBytes()
getSaltBytes in interface IPasswordSaltnull nor empty.@Nonnull @Nonempty public String getSaltString()
getSaltString in interface IPasswordSaltnull nor empty.@Nullable public static PasswordSalt createFromStringMaybe(@Nullable String sSalt)
PasswordSalt object from the passed string. First
the string is hex decoded into a byte array and this is the password salt.sSalt - The string to be used. May be null.null if the passed salt string is null or
empty.IllegalArgumentException - if the passed salt string cannot be hex decoded.Copyright © 2016–2019 Philip Helger. All rights reserved.