Package org.pgpainless.util
Class Passphrase
- java.lang.Object
-
- org.pgpainless.util.Passphrase
-
public class Passphrase extends Object
-
-
Constructor Summary
Constructors Constructor Description Passphrase(char[] chars)Passphrase for keys etc.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Overwrite the char array with spaces and mark thePassphraseas invalidated.static PassphraseemptyPassphrase()Represents aPassphraseinstance that represents no password.booleanequals(Object obj)static PassphrasefromPassword(String password)Create aPassphrasefrom aString.char[]getChars()Return a copy of the underlying char array.inthashCode()booleanisEmpty()Return true if the passphrase represents no password.booleanisValid()Return true if the passphrase has not yet been cleared.
-
-
-
Constructor Detail
-
Passphrase
public Passphrase(@Nullable char[] chars)
Passphrase for keys etc.- Parameters:
chars- may be null for empty passwords.
-
-
Method Detail
-
fromPassword
public static Passphrase fromPassword(@Nonnull String password)
Create aPassphrasefrom aString.- Parameters:
password- password- Returns:
- passphrase
-
clear
public void clear()
Overwrite the char array with spaces and mark thePassphraseas invalidated.
-
getChars
@Nullable public char[] getChars()
Return a copy of the underlying char array. A return value ofnullrepresents 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
public static Passphrase emptyPassphrase()
Represents aPassphraseinstance that represents no password.- Returns:
- empty passphrase
-
-