mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-01-05 05:29:24 +01:00
Added get-sha512.ps1
This commit is contained in:
parent
63ffa48dc4
commit
6e6974ec08
@ -3,10 +3,11 @@
|
||||
Prints the MD5 checksum of a file
|
||||
.DESCRIPTION
|
||||
This PowerShell script calculates and prints the MD5 checksum of the given file.
|
||||
.PARAMETER file
|
||||
Specifies the path to the file
|
||||
NOTE: MD5 is no longer considered secure, use it for simple change validation only!
|
||||
.PARAMETER path
|
||||
Specifies the file path to the file
|
||||
.EXAMPLE
|
||||
PS> ./get-md5 C:\MyFile.txt
|
||||
PS> ./get-md5.ps1 C:\MyFile.txt
|
||||
✅ MD5 hash is 041E16F16E60AD250EB794AF0681BD4A
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -14,16 +15,17 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$file = "")
|
||||
param([string]$path = "")
|
||||
|
||||
try {
|
||||
if ($file -eq "" ) { $file = Read-Host "Enter path to file" }
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the file path" }
|
||||
if (-not(Test-Path $path -pathType leaf)) { throw "Invalid file path given: $path" }
|
||||
|
||||
$Result = Get-Filehash $file -algorithm MD5
|
||||
$result = Get-FileHash -path $path -algorithm MD5
|
||||
|
||||
"✅ MD5 hash is $($Result.Hash)"
|
||||
"✅ MD5 hash is $($result.Hash)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Prints the SHA1 checksum of a file
|
||||
Prints the SHA1 hash of a file
|
||||
.DESCRIPTION
|
||||
This PowerShell script calculates and prints the SHA1 checksum of the given file.
|
||||
.PARAMETER file
|
||||
Specifies the path to the file
|
||||
NOTE: SHA1 is no longer considered secure, use it for simple change validation only!
|
||||
.PARAMETER path
|
||||
Specifies the local file path to the file
|
||||
.EXAMPLE
|
||||
PS> ./get-sha1 C:\MyFile.txt
|
||||
PS> ./get-sha1.ps1 C:\MyFile.txt
|
||||
✅ SHA1 hash is 8105D424D350E308AED92BD9DDEB74A1B53C5D7C
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -14,16 +15,17 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$file = "")
|
||||
param([string]$path = "")
|
||||
|
||||
try {
|
||||
if ($file -eq "" ) { $file = Read-Host "Enter the filename" }
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the file path" }
|
||||
if (-not(Test-Path $path -pathType leaf)) { throw "Invalid file path given: $path" }
|
||||
|
||||
$Result = get-filehash $file -algorithm SHA1
|
||||
$result = Get-FileHash -path $path -algorithm SHA1
|
||||
|
||||
"✅ SHA1 hash is $($Result.Hash)"
|
||||
"✅ SHA1 hash is $($result.Hash)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
@ -1,29 +1,30 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Prints the SHA256 checksum of a file
|
||||
Prints the SHA256 hash of a file
|
||||
.DESCRIPTION
|
||||
This PowerShell script calculates and prints the SHA256 checksum of the given file.
|
||||
.PARAMETER file
|
||||
Specifies the path to the file
|
||||
.PARAMETER path
|
||||
Specifies the local file path to the file
|
||||
.EXAMPLE
|
||||
PS> ./get-sha256 C:\MyFile.txt
|
||||
✅ SHA256 hash is: CEB4AD71524996EB8AA3ADCE04F1E45636A4B58B8BF4462E6971CF2E56B4293E
|
||||
PS> ./get-sha256.ps1 C:\MyFile.txt
|
||||
✅ SHA256 hash is CEB4AD71524996EB8AA3ADCE04F1E45636A4B58B8BF4462E6971CF2E56B4293E
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$file = "")
|
||||
param([string]$path = "")
|
||||
|
||||
try {
|
||||
if ($file -eq "" ) { $file = Read-Host "Enter the filename" }
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the file path" }
|
||||
if (-not(Test-Path $path -pathType leaf)) { throw "Invalid file path given: $path" }
|
||||
|
||||
$Result = get-filehash $file -algorithm SHA256
|
||||
$result = Get-FileHash -path $path -algorithm SHA256
|
||||
|
||||
"✅ SHA256 hash is: $($Result.Hash)"
|
||||
"✅ SHA256 hash is $($result.Hash)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
|
30
scripts/get-sha512.ps1
Normal file
30
scripts/get-sha512.ps1
Normal file
@ -0,0 +1,30 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Prints the SHA512 hash of a file
|
||||
.DESCRIPTION
|
||||
This PowerShell script calculates and prints the SHA512 checksum of the given file.
|
||||
.PARAMETER path
|
||||
Specifies the local file path to the file
|
||||
.EXAMPLE
|
||||
PS> ./get-sha512.ps1 C:\MyFile.txt
|
||||
✅ SHA512 hash is CEB4AD71524996EB8AA3ADCE04F1E45636A4B58B8BF4462E6971CF2E56B4293E
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$path = "")
|
||||
|
||||
try {
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the file path" }
|
||||
if (-not(Test-Path $path -pathType leaf)) { throw "Invalid file path given: $path" }
|
||||
|
||||
$result = Get-FileHash -path $path -algorithm SHA512
|
||||
|
||||
"✅ SHA512 hash is $($result.Hash)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user