mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 05:04:39 +02:00
Improve description
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Decrypts the given file
|
||||
Decrypts a file
|
||||
.DESCRIPTION
|
||||
This PowerShell script decrypts the given file.
|
||||
This PowerShell script decrypts a file using the given password and AES encryption.
|
||||
.PARAMETER Path
|
||||
Specifies the path to the file to decrypt
|
||||
.PARAMETER Password
|
||||
@ -12,44 +12,13 @@
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Path = "", [string]$Password = "")
|
||||
|
||||
|
||||
function DecryptFile {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Decrypts a file encrypted with Protect-File.
|
||||
|
||||
.DESCRIPTION
|
||||
Decrypts a file using a provided cryptography key.
|
||||
|
||||
.PARAMETER FileName
|
||||
File(s) to be decrypted.
|
||||
|
||||
.PARAMETER Key
|
||||
Cryptography key as a SecureString be used for decryption.
|
||||
|
||||
.PARAMETER KeyAsPlainText
|
||||
Cryptography key as a String to be used for decryption.
|
||||
|
||||
.PARAMETER CipherMode
|
||||
Specifies the block cipher mode that was used for encryption.
|
||||
|
||||
.PARAMETER PaddingMode
|
||||
Specifies the type of padding that was applied when the message data block was shorter than the full number of bytes needed for a cryptographic operation.
|
||||
|
||||
.PARAMETER Suffix
|
||||
Suffix of the encrypted file to be removed.
|
||||
|
||||
.PARAMETER RemoveSource
|
||||
Removes the source (encrypted) file after decrypting.
|
||||
|
||||
.OUTPUTS
|
||||
System.IO.FileInfo. Unprotect-File will return FileInfo with the SourceFile as an added NoteProperty
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName='SecureString')]
|
||||
[OutputType([System.IO.FileInfo[]])]
|
||||
Param(
|
||||
@ -163,11 +132,13 @@ Param(
|
||||
try {
|
||||
if ($Path -eq "" ) { $Path = read-host "Enter path to file" }
|
||||
if ($Password -eq "" ) { $Password = read-host "Enter password" }
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
$PasswordBase64 = [System.Convert]::ToBase64String($Password)
|
||||
DecryptFile "$Path" -algorithm AES -keyAsPlainText $PasswordBase64 -removeSource
|
||||
DecryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource
|
||||
|
||||
"✔️ Done."
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ file decrypted in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Reference in New Issue
Block a user