-
-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Description
Feature Request: Option to save Checksums to Alternate Data Stream
- Option to write the computer checksum to ADS streams
- example of ADS names that I've been using:
hash.sha256,hash.crc32,hash.sha512
- example of ADS names that I've been using:
- Option to verify checksum from ADS (if it exists)
I have this is my PowerShell profile, and have been using on the command-line - but a GUI version would be great (It's on my TODO list as a project, but it's a long TODO list)
I actually use a longer script
function add_checksums_to_ads {
param (
[Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
[string[]]$FilePaths
)
$files = Get-ChildItem -File -Recurse -Attributes !System # !System+!ReadOnly
foreach ($file in $files) {
$ads = "$($file.FullName):hash.sha256"
if (Test-Path -LiteralPath $ads) {
$current_checksum = Get-Content -Path "$($file.FullName)" -Stream "hash.sha256"
$checksum = Get-FileHash -Path "$($file.FullName)" -Algorithm SHA256 | Select-Object -ExpandProperty Hash
Write-Host -NoNewline "$($file.Name) already has a 'hash.sha256'"
if ($checksum -eq $current_checksum) {
Write-Host " ✅�[32;1mChecksums match�[0m"
} else {
Write-Host " ❌�[31;1mCurrent checksum and computer don't match!!!�[0m"
}
} else {
Write-Host -NoNewline "$($file.Name) generating 'hash.sha256'"
$lastWriteTime = $file.LastWriteTime
# SHA256, SHA384, SHA512
$checksum = Get-FileHash -Path "$($file.FullName)" -Algorithm SHA256 | Select-Object -ExpandProperty Hash
try {
#Write-Host "$checksum"
Set-Content -Force -Path "$($file.FullName)" -Stream "hash.sha256" -Value $checksum
Write-Host " $checksum"
} catch {
Write-Host " Failed to write ADS 'hash.sha256' to $file [$_]"
}
try {
#Write-Host "Reseting LastWriteTime"
$file.LastWriteTime = $lastWriteTime
} catch {
Write_host "Failed to reset LastWriteTime on $file"
}
}
}
}Metadata
Metadata
Assignees
Labels
No labels