Skip to content

Commit

Permalink
Use SHA256 for the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jviau committed Jan 8, 2025
1 parent 3989192 commit 9adf37f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/WebJobs.Script.SiteExtension/Tasks.targets
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ for (int i = 0; i < Directories.Length; i++)
</Task>
</UsingTask>

<!-- Not using built in 'GetFileHash' task for 2 reasons: 1. MD5 support, 2. built in task fails for max path length. -->
<!-- Not using built in 'GetFileHash' task as it errors out with long paths. -->
<UsingTask TaskName="GetFileHash_Custom" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
Expand All @@ -116,7 +116,7 @@ for (int i = 0; i < Directories.Length; i++)
{
var file = Files[i];
using (var stream = File.OpenRead(file.ItemSpec))
using (var algorithm = MD5.Create())
using (var algorithm = SHA256.Create())
{
byte[] hash = algorithm.ComputeHash(stream);
file.SetMetadata("FileHash", Convert.ToBase64String(hash));
Expand Down

0 comments on commit 9adf37f

Please sign in to comment.