Package org.pgpainless.util
Class Passphrase
java.lang.Object
org.pgpainless.util.Passphrase
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Overwrite the char array with spaces and mark thePassphrase
as invalidated.static Passphrase
Represents aPassphrase
instance that represents no password.boolean
static Passphrase
fromPassword
(String password) Create aPassphrase
from aString
.char[]
getChars()
Return a copy of the underlying char array.int
hashCode()
boolean
isEmpty()
Return true if the passphrase represents no password.boolean
isValid()
Return true if the passphrase has not yet been cleared.
-
Field Details
-
lock
-
-
Constructor Details
-
Passphrase
public Passphrase(@Nullable char[] chars) Passphrase for keys etc.- Parameters:
chars
- may be null for empty passwords.
-
-
Method Details
-
fromPassword
Create aPassphrase
from aString
.- Parameters:
password
- password- Returns:
- passphrase
-
clear
public void clear()Overwrite the char array with spaces and mark thePassphrase
as invalidated. -
getChars
@Nullable public char[] getChars()Return a copy of the underlying char array. A return value ofnull
represents no password.- Returns:
- passphrase chars.
- Throws:
IllegalStateException
- in case the password has been cleared at this point.
-
isValid
public boolean isValid()Return true if the passphrase has not yet been cleared.- Returns:
- valid
-
isEmpty
public boolean isEmpty()Return true if the passphrase represents no password.- Returns:
- empty
-
emptyPassphrase
Represents aPassphrase
instance that represents no password.- Returns:
- empty passphrase
-
hashCode
public int hashCode() -
equals
-