Package page.codeberg.friedolyn.crypto
Class PasswordGenerator
java.lang.Object
page.codeberg.friedolyn.crypto.PasswordGenerator
A class that generates secure passwords and passphrases. It uses the EFF word list to
generate password
, which are easy to remember and type, but not as secure as random
passwords. The strength of a password can be estimated with the estimatePasswordStrength(char[])
method,
which uses the Zxcvbn
library.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Indicates how hard it is to guess a specific password. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe EFF word list, a list of 7776 words that can be used to generate passphrases. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull PasswordGenerator.PasswordStrength
estimatePasswordStrength
(char[] password) Uses theZxcvbn
library to check how hard the given passsword is to guess.char[]
Generates a securely random passphrase consisting of 6 words from the EFF word list.
-
Field Details
-
EFF_WORD_LIST
-
-
Constructor Details
-
PasswordGenerator
Loads the EFF word list from the resources. The EFF word list is a list of 7776 words that can be used to generate passphrases. Without it, thegeneratePassphrase()
method will not work.- Throws:
RuntimeException
- If the EFF word list could not be loaded.
-
-
Method Details
-
generatePassphrase
Generates a securely random passphrase consisting of 6 words from the EFF word list. The strength of the passphrase is not too high if the attacker knows that it only consists of natural language words. However, it is easy to remember and type, which is why it is suitable for some use cases, e.g. when the user does not have a password manager available.- Returns:
- A passphrase consisting of 6 words from the EFF word list.
- Throws:
RuntimeException
- Should not happen. If it does, it means that the EFF word list could not be loaded.
-
estimatePasswordStrength
@NonNull public static @NonNull PasswordGenerator.PasswordStrength estimatePasswordStrength(char[] password) Uses theZxcvbn
library to check how hard the given passsword is to guess.- Parameters:
password
- The password to estimate the strength of.- Returns:
- The estimated strength of the password, according to
Zxcvbn
.
-