Cipher Command - Everything You Need To Know (Windows, CMD, DOS)

What Is The Cipher Command?

The cipher command is a built in security tool, available in the windows command line, that can be used to perform a number of operations on your files and folders. Cipher can come in very handy if you are constancy working with important files or manage sensitive data. That’s because cipher can be used to securely and fully encrypt and decrypt files or entire directories as well as securely wipe or overwrite deleted data making them unrecoverable. We are going to learn how to do just that in this short guide. If you would like to follow along, feel free to open your command line (not as an administrator) and create an empty file using the echo command and the grater than redirector as well as a folder using the mkdir command.

echo. > File.txt & mkdir Folder

An empty file will be created at once in your current directory. We are going to use this file to practice a number of cipher commands starting with encryption and decryption.

How To Encrypt & Decrypt Using Cipher:

Using the cipher command to securely encrypt a single file is extremely easy, simply type the cipher command along withe the /e parameter followed by the name of the file. The /e parameter stands for encrypt.

Cipher /e File.txt

Your file will immediately be encrypted.
To undo the operation and decrypt the file simply replace the /e parameter with /d, which stands for decrypt.

Cipher /d File.txt 

To check whether or not your file was indeed encrypted/decrypted use the cipher command without any parameters followed by the name of your file or folder:

Cipher File.txt

The encryption status of your file or folder should appear at once.

 

  • If the result is U it means that the file is unencrypted.
  • If the result is E it means that the file is encrypted.

Typing the name of your file directly, only woks on files that are located in the same directory as your command line, to encrypt a file that’s located elsewhere, type the path to your file followed by a backward slash and the name of your file. For example to encrypt a file named “My File.txt” in your desktop directory use the following syntax:

Cipher /e "C:\Users\<Username>\My File.txt"

Replace <Username> with your computers username. You might have noticed that i surrounded the location of the file in quotes, that’s because the path/location to the file contains a space within it. Had i not added the quotes, the command line would not have been be able to find my file. That’s because the quotes tell the command line that the words separated by the spaces are not an additional parameter and are just a continuation of the location or name of our file/folder. So remember to always wrap quotes around locations or file names that contain spaces so that the command line knows how to properly search for your file.
The command for encrypting and decrypting a folder is exactly the same.

Cipher /e Folder

Replace the /e parameter with /d to decrypt the folder instead.
This operation however will only perform the operation on the folder itself and not any of the contents inside it. To encrypt/decrypt every item within the folder you need to use the /s parameter. Here is what the command would look like:

Cipher /e /s:Folder

The specified operation will now be performed on all the contents inside your folder as well.

Encrypt & Decrypt Multiple Files/Folders At Once:

So far we have been using cipher to perform an operation only a single file or folder. We can encrypt/decrypt  multiple files or folders at once either by typing their names one after the other, for example:

Cipher /e File1.txt File2.txt File3.txt

Or by using wildcards. Wildcards are special symbols or characters that take the place of characters or words. For example to encrypt or decrypt every text file, in your current directory, that has the word “file” in its name type the following:

Cipher /e File*.txt

Apart from encrypting/decrypting every text file, you can even use a wildcard to decrypt every file and folder in your current directory.

Cipher /e *

To encrypt/decrypt every file of a different directory type the location of the directory followed by a backwards slash and the asterisk wildcard. 

Cipher /e "C:\Users\<Username>\Desktop\*"

Replace <Username> with your computers name.

Make Deleted Data Unrecoverable Using Cipher:

Apart from encrypting or decrypting files, cipher can be used to wipe/override all your empty space, making deleted data completely unrecoverable. To do so use cipher with the /w parameter along with the name of the drive you want to overwrite.

Cipher /wC:\

Keep in mind that this operation will take quite a long time to complete, to cancel use Control + C. Its recommended that you close every other application when wiping data so that cipher can overwrite as much data as possible.
You can also wipe the deleted data of a specific directory. For example:

Cipher /wC:\Users\<Username>\Desktop

Replace <Username> with your computers name.

Useful Parameters & Options:

  •  /e    Encrypts files and folders.
  •  /d    Decrypts files and folders.
  •  /w   Stands for Wipe. Overrides empty space on a drive or a directory.
  •  /s    Performs the specified operation on a folder recursively.
  •  /f     Stands for force. Performs the specified operation on every selected file including any files that have already been         encrypted/decrypted.
  •  /q    Reports only essential information.
  •  /h    Displays and operates on files with the hidden or system attributes.
  •  /k    Creates a new file encryption key for the current user.

Examples:

Check whether a file is encrypted.

Cipher File.txt

Encrypt a file.

Cipher /e File.txt

Decrypt a file.

Cipher /d File.txt

Decrypt a file named My File that’s located at the desktop directory. Replace with your computers name.

Cipher /e "C:\Users\\Desktop\My File.txt"

Encrypt the a folder along with every item within it.

Cipher /e /s:Folder

Decrypt every text file in the current directory.

Cipher /d *.txt

Overwrite all the empty data on the C drive.

Cipher /wC:\

Overwrite all the empty data on the desktop directory.Replace with your computers name.

Cipher /w"C:\Users\\Desktop\*"

Want to learn more about the Command Line?

Available on Udemy with a 70% discount.
Only for readers like you!

Scroll to top