Skip to content

Commit

Permalink
Memory optimization in CreateHash by using
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco authored and Marco committed Apr 5, 2021
1 parent ff78b93 commit ee5d384
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions RDFSharp/Model/RDFModelUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public static class RDFModelUtilities

#region Hashing
/// <summary>
/// Performs MD5 hash calculation of the given string
/// Creates a unique long representation of the given string
/// </summary>
public static long CreateHash(string input)
{
if (input != null)
if (input == null)
throw new RDFModelException("Cannot create hash because given \"input\" string parameter is null.");

using (MD5CryptoServiceProvider md5Encryptor = new MD5CryptoServiceProvider())
{
var md5Encryptor = new MD5CryptoServiceProvider();
var inputBytes = Encoding.UTF8.GetBytes(input);
var hashBytes = md5Encryptor.ComputeHash(inputBytes);
byte[] hashBytes = md5Encryptor.ComputeHash(Encoding.UTF8.GetBytes(input));
return BitConverter.ToInt64(hashBytes, 0);
}
throw new RDFModelException("Cannot create hash because given \"input\" string parameter is null.");
}
#endregion

Expand Down

0 comments on commit ee5d384

Please sign in to comment.