Skip to content

Commit

Permalink
bugfix(crypto): Shiro 1 hash parser now supports unsalter passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Jan 4, 2024
1 parent 78fca2f commit ab7d4ba
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ public Hash parse(final String formatted) {
String iterationsString = parts[i--];

byte[] digest = Base64.decode(digestBase64);
ByteSource salt = null;
ByteSource salt;

if (StringUtils.hasLength(saltBase64)) {
byte[] saltBytes = Base64.decode(saltBase64);
salt = ByteSource.Util.bytes(saltBytes);
} else {
salt = ByteSource.Util.bytes(new byte[0]);
}

int iterations;
Expand All @@ -174,9 +176,7 @@ public Hash parse(final String formatted) {

SimpleHash hash = new SimpleHash(algorithmName);
hash.setBytes(digest);
if (salt != null) {
hash.setSalt(salt);
}
hash.setSalt(salt);
hash.setIterations(iterations);

return hash;
Expand Down

0 comments on commit ab7d4ba

Please sign in to comment.