Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/main/java/org/mindrot/BCrypt.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

import java.io.UnsupportedEncodingException;

import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;

/**
Expand Down Expand Up @@ -447,7 +447,7 @@ private static byte[] decode_base64(String s, int maxolen)
byte c1, c2, c3, c4, o;

if (maxolen <= 0)
throw new IllegalArgumentException ("Invalid maxolen");
throw new IllegalArgumentException("Invalid maxolen");

while (off < slen - 1 && olen < maxolen) {
c1 = char64(s.charAt(off++));
Expand Down Expand Up @@ -673,11 +673,7 @@ public static String hashpw(String password, String salt) {
rounds = Integer.parseInt(salt.substring(off, off + 2));

real_salt = salt.substring(off + 3, off + 25);
try {
passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8");
} catch (UnsupportedEncodingException uee) {
throw new AssertionError("UTF-8 is not supported");
}
passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes(StandardCharsets.UTF_8);

saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);

Expand Down Expand Up @@ -761,13 +757,9 @@ public static String gensalt() {
public static boolean checkpw(String plaintext, String hashed) {
byte hashed_bytes[];
byte try_bytes[];
try {
String try_pw = hashpw(plaintext, hashed);
hashed_bytes = hashed.getBytes("UTF-8");
try_bytes = try_pw.getBytes("UTF-8");
} catch (UnsupportedEncodingException uee) {
return false;
}
String try_pw = hashpw(plaintext, hashed);
hashed_bytes = hashed.getBytes(StandardCharsets.UTF_8);
try_bytes = try_pw.getBytes(StandardCharsets.UTF_8);
if (hashed_bytes.length != try_bytes.length)
return false;
byte ret = 0;
Expand Down