public class PasswordUtil extends Object
| Constructor and Description |
|---|
PasswordUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
secureCompare(String input,
String password,
int loops)
Securely compares two strings up to a maximum number of characters in a way
that obscures the password length from timing attacks
|
static boolean |
secureCompareFast(String input,
String password)
Securely compares two strings forcing the number of loops equal to password length
thereby obscuring the password length based on user input
|
public static boolean secureCompare(String input, String password, int loops)
input - user inputpassword - correct passwordloops - number of characters to compare; must be larger than password
length; 1024 is a good numberIllegalArgumentException - when the limit is less than the password lengthpublic static boolean secureCompareFast(String input, String password)
input - user inputpassword - correct passwordIllegalArgumentException - when the limit is less than the password lengthCopyright © 2003–2025 The Apache Software Foundation. All rights reserved.