Bug fixes

This commit is contained in:
Isaac Levy 2017-09-23 15:39:24 -04:00
parent 659b789adf
commit 307ef00e5a
2 changed files with 8 additions and 5 deletions

View file

@ -240,13 +240,13 @@ object UserRepo {
_id: String,
bpass: Option[Array[Byte]],
password: Option[String],
salt: String,
salt: Option[String],
sha512: Option[Boolean]
) {
def compare(p: String) = {
val newP = (password, sha512) match {
case (None, None) => p
case _ => (~sha512).fold(salted(p, salt).sha512, salted(p, salt).sha1).hex
case _ => (~sha512).fold(salted(p, ~salt).sha512, salted(p, ~salt).sha1).hex
}
bpass match {

View file

@ -644,13 +644,16 @@ public final class BCrypt {
encipher(cdata, j);
}
ret = new byte[C_LEN * 4];
for (i = 0, j = 0; i < C_LEN; i++) {
ret = new byte[C_LEN * 4 - 1];
for (i = 0, j = 0; i < C_LEN - 1; i++) {
ret[j++] = (byte)(cdata[i] >>> 24);
ret[j++] = (byte)(cdata[i] >>> 16);
ret[j++] = (byte)(cdata[i] >>> 8);
ret[j++] = (byte)cdata[i];
}
ret[j++] = (byte)(cdata[C_LEN - 1] >>> 24);
ret[j++] = (byte)(cdata[C_LEN - 1] >>> 16);
ret[j++] = (byte)(cdata[C_LEN - 1] >>> 8);
return ret;
}
@ -714,7 +717,7 @@ public final class BCrypt {
rs.append(Integer.toString(rounds));
rs.append("$");
rs.append(encode_base64(saltb, saltb.length));
rs.append(encode_base64(hashed, C_LEN * 4 - 1));
rs.append(encode_base64(hashed, hashed.length));
return rs.toString();
}