Windows has native support for file encryption. This is called Encrypting File System or EFS in short. For EFS supported editions and other information check out this post Encrypting File System supported editions in Windows.
In this post I am going to explain how to encrypt files and directories from Windows command line. Windows has in-built command cipher.exe for this purpose. I am going to explain below how to use this command.
Encrypt file from Windows command line:
To perform encryption on a single file you can run the below command.
cipher /A /E filename
To perform encryption on a list of files:
cipher /A /E filename1 filename2 filename3
Encrypt folder:
By encrypting a folder we can make sure that all the files that will be added to the folder in future will be automatically encrypted.
To encrypt a directory we can run the below command.
cipher /E directoryname
To encrypt all the files in a folder:
Cipher command accepts wild cards. So we can run the below command to encrypt all the files in a folder.
cipher /E directoryname\*
For example to encrypt all the files in the folder E:\docs, the command would be as below.
cipher /E E:\docs\*
Encrypt a folder including all subfolders:
We can add /S switch to perform encryption recursively on each of the subfolders.
cipher /E /S:directoryname
Note that this command does not encrypt the existing files in the folder and its subfolders. Only the files that will be added now onwards will be encrypted.
Encrypt folder and files:
Encrypt a folder and all the files and subfolders in that directory.
cipher /A /E / S:directoryname
Decrypting files and folder:
The commands for file/folder decryption are similar to the ones mentioned in the above cases. You just need to replace /E with /D.
{ 0 comments… add one now }