NetCmdlets 2016
NetCmdlets 2016
Questions / Feedback?

Protect-Data Cmdlet

Parameters   Output Objects   Configuration Settings  

The Protect-Data cmdlet supports encrypting data with various symmetric algorithms including AES, 3DES, and more.

Syntax

Protect-Data [parameters]

Remarks

The Protect-Data cmdlet provides a simple way to encrypt data or files. The following encryption 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 encrypted 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 desired. Additional parameters that affect the encryption algorithm include CipherMode and PaddingMode.

If the output will be stored as a string set UseHex to hex encode the output before encrypting. This makes storage and transmission of the data easier.

Additional options include specifying Key and InitializationVector instead of KeyPassword, encrypting 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.

LogFileThe location of a file to which debug information is written.
AlgorithmThe encryption algorithm.
CharsetThe character set of the data.
CipherModeThe cipher mode of operation.
ConfigSpecifies one or more configuration settings.
InitializationVectorThe initialization vector (IV).
InputBlockBA block of data to encrypt.
InputFileThe file to process.
InputMessageThe message to process.
InputMessageBThe message to process.
IVBThe initialization vector (IV).
KeyThe secret key for the symmetric algorithm.
KeyBThe secret key for the symmetric algorithm.
KeyPasswordA password to generate the Key and InitializationVector .
LastBlockWhether the input block is the last block.
LogFileThe location of a file to which debug information is written.
OutputFileSpecifies the output file.
OverwriteWhether to overwrite the output file.
PaddingModeThe padding mode.
UseHexWhether 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.

OutputBlockThe encrypted block.
OutputMessageThe 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.

KeySizeThe size, in bits, of secret key for the symmetric algorithm.
BlockSizeThe block size, in bits, of the cryptographic operation.
IncludeIVWhether to prepend the IV to the output data and read the IV from the input data.
KeyPasswordAlgorithmThe hash algorithm used to derive the Key and IV from the KeyPassword property.
KeyPasswordSaltThe salt value used in conjunction with the KeyPassword to derive the Key and IV.
CodePageThe system code page used for Unicode to Multibyte translations.

 
 
Copyright (c) 2017 /n software inc. - All rights reserved.
NetCmdlets 2016 - Version 16.0 [Build 6335]