Replace MD5 hash with a longer simple hash
This commit is contained in:
@ -144,7 +144,7 @@ namespace Oqtane.Pages
|
|||||||
etagInput += $":{Request.QueryString.Value}";
|
etagInput += $":{Request.QueryString.Value}";
|
||||||
}
|
}
|
||||||
|
|
||||||
etag = Utilities.GenerateHashMD5(etagInput);
|
etag = Utilities.GenerateSimpleHash16(etagInput);
|
||||||
|
|
||||||
var header = "";
|
var header = "";
|
||||||
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
if (HttpContext.Request.Headers.TryGetValue(HeaderNames.IfNoneMatch, out var ifNoneMatch))
|
||||||
|
@ -620,11 +620,17 @@ namespace Oqtane.Shared
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GenerateHashMD5(string input)
|
public static string GenerateSimpleHash16(string text)
|
||||||
{
|
{
|
||||||
var bytes = Encoding.UTF8.GetBytes(input);
|
unchecked // prevent overflow exception
|
||||||
var hashBytes = MD5.HashData(bytes);
|
{
|
||||||
return Convert.ToHexString(hashBytes);
|
long hash = 23;
|
||||||
|
foreach (char c in text)
|
||||||
|
{
|
||||||
|
hash = hash * 31 + c;
|
||||||
|
}
|
||||||
|
return hash.ToString("X16");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("ContentUrl(Alias alias, int fileId) is deprecated. Use FileUrl(Alias alias, int fileId) instead.", false)]
|
[Obsolete("ContentUrl(Alias alias, int fileId) is deprecated. Use FileUrl(Alias alias, int fileId) instead.", false)]
|
||||||
|
Reference in New Issue
Block a user