Package org.pgpainless.util

# Class Passphrase

java.lang.Object
org.pgpainless.util.Passphrase

public class Passphrase extends Object

## Field Summary

Fields
Modifier and Type
Field
Description
`final Object`
`lock`

## Constructor Summary

Constructors
Constructor
Description
`Passphrase(char[] chars)`
Passphrase for keys etc.

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Overwrite the char array with spaces and mark the `Passphrase` as invalidated.
`static Passphrase`
`emptyPassphrase()`
Represents a `Passphrase` instance that represents no password.
`boolean`
`equals(Object obj)`
`static Passphrase`
`fromPassword(String password)`
Create a `Passphrase` from a `String`.
`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.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### lock

public final Object lock

## Constructor Details

### Passphrase

public Passphrase(@Nullable char[] chars)
Passphrase for keys etc.

Parameters:
  `chars` - may be null for empty passwords.

## Method Details

### fromPassword

public static Passphrase fromPassword(@Nonnull String password)
Create a `Passphrase` from a `String`.

Parameters:
  `password` - password
Returns:
  passphrase

### clear

public void clear()
Overwrite the char array with spaces and mark the `Passphrase` as invalidated.

### getChars

@Nullable public char[] getChars()
Return a copy of the underlying char array. A return value of `null` 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

public static Passphrase emptyPassphrase()
Represents a `Passphrase` instance that represents no password.

Returns:
  empty passphrase

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`