Created
January 31, 2022 02:21
-
-
Save kylec32/508da451cb2207455485a4a82602a590 to your computer and use it in GitHub Desktop.
Timing Side-Channel Mitigated Password Checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean verifyPassword(String realPassword, String providedPassword) { | |
if (realPassword.length() != providedPassword.length()) { | |
return false; | |
} | |
int result = 0; | |
for (int i = 0; i < realPassword.length(); i++) { | |
result |= realPassword.charAt(i) ^ providedPassword.charAt(i); | |
} | |
return result == 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment