Unprotect-Data Cmdlet
Parameters Output Objects Configuration Settings
The Unprotect-Data cmdlet supports decrypting data with various symmetric algorithms including AES, 3DES, and more.
Syntax
Unprotect-Data [parameters]
Remarks
The Unprotect-Data cmdlet provides a simple way to decrypt data or files. The following algorithms are supported:
- AES (default)
- Blowfish
- CAST
- DES
- IDEA
- RC2
- RC4
- TEA
- TripleDES
- Twofish
- Rijndael
To begin, specify the input data through either InputMessage or InputFile. If OutputFile is set the decrypted data will be written to the specified file, otherwise it will be returned in the OutputMessage object.
Next, set KeyPassword, and specify the Algorithm if required. Additional parameters that affect the algorithm include CipherMode and PaddingMode.
If the input is hex encoded set UseHex to hex decode the input before decrypting.
Additional options include specifying Key and InitializationVector instead of KeyPassword, decrypting block-by-block via InputBlockB, specifying KeySize, KeyPasswordAlgorithm, and more.
Encrypt Examples
#Encrypt a string with AES and default options
$encryptedData = Protect-Data -InputMessage test -KeyPassword password
#Encrypt a string to file with 3DES
Protect-Data -InputMessage test -KeyPassword password -OutputFile C:\encrypted.dat -Algorithm tripledes
#Encrypt a file to string and hex encode it
Protect-Data -InputFile C:\test.txt -KeyPassword password -UseHex
Decrypt Examples
#Decrypt a string with AES
Unprotect-Data -InputMessageB $encryptedData.DataB -KeyPassword password
#Decrypt a file to string with 3DES
Unprotect-Data -InputFile C:\encrypted.dat -KeyPassword password -Algorithm tripledes
#Decrypt a string to file and hex decode it
Unprotect-Data -InputMessage ADE51B29E36B2C1FCB4C9A1BEB8884AE -KeyPassword password -UseHex -OutputFile C:\test.decrypted.txt
Parameter List
The following is the full list of the parameters of the cmdlet with short descriptions. Click on the links for further details.
LogFile | The location of a file to which debug information is written. |
Algorithm | The encryption algorithm. |
Charset | The character set of the data. |
CipherMode | The cipher mode of operation. |
Config | Specifies one or more configuration settings. |
InitializationVector | The initialization vector (IV). |
InputBlockB | A block of data to decrypt. |
InputFile | The file to process. |
InputMessage | The message to process. |
InputMessageB | The message to process. |
IVB | The initialization vector (IV). |
Key | The secret key for the symmetric algorithm. |
KeyB | The secret key for the symmetric algorithm. |
KeyPassword | A password to generate the Key and InitializationVector . |
LastBlock | Whether the input block is the last block. |
LogFile | The location of a file to which debug information is written. |
OutputFile | Specifies the output file. |
Overwrite | Whether to overwrite the output file. |
PaddingMode | The padding mode. |
UseHex | Whether input or output is hex encoded. |
Output Objects
The following is the full list of the output objects returned by the cmdlet with short descriptions. Click on the links for further details.
OutputBlock | The decrypted block. |
OutputMessage | The output message. |
Configuration Settings
The following is a list of configuration settings for the cmdlet with short descriptions. Click on the links for further details.
KeySize | The size, in bits, of secret key for the symmetric algorithm. |
BlockSize | The block size, in bits, of the cryptographic operation. |
IncludeIV | Whether to prepend the IV to the output data and read the IV from the input data. |
KeyPasswordAlgorithm | The hash algorithm used to derive the Key and IV from the KeyPassword property. |
KeyPasswordSalt | The salt value used in conjunction with the KeyPassword to derive the Key and IV. |
UseBackgroundThread | Whether threads created by the cmdlet are background threads. |
UseInternalSecurityAPI | Tells the cmdlet whether or not to use the system security libraries or an internal implementation. |