Skip to content

Commit cc76b4b

Browse files
authored
Revived ComputeHashWithSaltInternal for Argon2id
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent 1000583 commit cc76b4b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

HashifyNet/Algorithms/Argon2id/Argon2id_Implementation.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,22 @@ internal IHashValue ComputeHashWithSaltInternal(ArraySegment<byte> data, byte[]
9090
Argon2Config config = Argon2idHelpers.GetArgon2Config(_config, data.Array, salt);
9191
string hash = Argon2.Hash(config);
9292

93-
return new EncodedHashValue(Argon2idSerializer.Serialize(hash), _config.HashSizeInBits);
93+
byte[] encodedHash = Argon2idSerializer.Serialize(hash);
94+
Argon2Config overwrite = new Argon2Config();
95+
if (!DecodeExtension.DecodeString(overwrite, hash, out var buffer))
96+
{
97+
throw new InvalidOperationException("Could not decode Argon2id hash.");
98+
}
99+
100+
try
101+
{
102+
return new EncodedHashValue(encodedHash, (i) => Argon2idSerializer.Deserialize((byte[])i), buffer.Buffer, _config.HashSizeInBits);
103+
}
104+
finally
105+
{
106+
buffer.Dispose();
107+
}
94108
}
95109
}
96-
}
110+
111+
}

0 commit comments

Comments
 (0)