Encrypting file or folders via cmd/bat/vbscript codes

  • Thread starter Arman777
  • Start date
  • Tags
    File
In summary, a way to encrypt personal data using basic commands is possible, but the key must be stored in a personalized way for the user.
  • #1
Arman777
Insights Author
Gold Member
2,168
193
I have some personal data then I want to encrypt however, I want to do it via some basic .vbs, cmd or .bat commands. Is there a way to do this and most importantly is there way to store the key via some personalized encryption method, so that I can open it whenever I want but someone else cant..

I am using Windows 10
 
Technology news on Phys.org
  • #2
Arman777 said:
I have some personal data then I want to encrypt however, I want to do it via some basic .vbs, cmd or .bat commands. Is there a way to do this
You will need a cryptography library. Here is a simple example with OpenSSL on Windows:



But they are lots of no-hassle solutions to do this also.

Arman777 said:
is there way to store the key via some personalized encryption method, so that I can open it whenever I want but someone else cant..
Maybe you would prefer a fingerprint encrypted USB flash drive?
 
  • Like
Likes FactChecker
  • #3
Arman777 said:
I have some personal data then I want to encrypt however, I want to do it via some basic .vbs, cmd or .bat commands.
Another option is to use WinZip or similar to put the files into a ZIP file, and password protect it:

1629128298708.png
 
  • Like
Likes hmmm27, sysprog, FactChecker and 1 other person
  • #4
I need to find a way to encrypt text, word, pdf files etc. So I need encrypt the data either from command line or through .bat or .vbs

[Mentor Note -- post has been edited to remove some questionable parts]
 
Last edited by a moderator:
  • Wow
Likes berkeman
  • #5
berkeman said:
Has somebody made you angry?
no ofc not :smile: I just want to encrypt and decrypt the files from the methods that I have mentioned earlier. I am not going to harm anyone or ask for money. I also saw this on Mr. Robot (and also in computerphile) couple of years ago and then I remembered maybe I can try to implement it myself. Maybe I can try to read data for each file type. For instance if its .txt I just normally read it, If its a word document I open it with some other python function and then encrypt the information inside.
 
  • #6
After some edits, the thread is re-opened.
 
  • #7
Arman777 said:
I have some personal data then I want to encrypt however, I want to do it via some basic .vbs, cmd or .bat commands. Is there a way to do this and most importantly is there way to store the key via some personalized encryption method, so that I can open it whenever I want but someone else cant..

I am using Windows 10
VBS has an XOR command ; you're all set.
 
  • #8
One thing in general about passwords and command line tools is that they don't allow you to either add the password as an argument on the command line or pass the password in via a pipe. This prevents the poor practice of possibly exposing the password in a script for all to see. Scripts with commands that require passwords will ask you when run to enter the password. However, you can't pass the password to the command via any kind of pipe.

The only way around the password entry limitation is to write a custom command line encrypting tool or modify an existing one to do what you want. As has been mentioned before, its best to use trusted encryption tools and not a custom algorithm as your custom algorithm will likely be easily crackable.

Command line zip and archiving tools like "zip" will usually have features to update the zip with changed files and remove deleted files as well as keeping them encrypted. This is a useful feature that can be used in backup scripts.

xcopy comes to mind as a command that can copy only changed files to create a backup disk too. Encryption and zipping to be done as a separate step.
 
  • #9
Arman777 said:
Maybe I can try to read data for each file type. For instance if its .txt I just normally read it, If its a word document I open it with some other python function and then encrypt the information inside.
I have a way to do it. It involves using "rb+" and an encryption tool such as AES. The idea is to read the file as binary and encrypt the binary data.

I have found a code that can do this task. I have changed a bit, and now I can encrypt all of these files types. Moreover, without a key, no one can access it.

.jpg
.txt
.pdf
.xlsx
.ppt/pptx
.docx
.png
.py
.wav

Probably it may encrypt more file types...

Now, all you have to do is find a way to access subdirectories of a directory and get all files and encrypt them one by one.
 

FAQ: Encrypting file or folders via cmd/bat/vbscript codes

How do I encrypt a file or folder using cmd/bat/vbscript codes?

To encrypt a file or folder using cmd/bat/vbscript codes, you can use the "cipher" command in cmd. The syntax for this command is "cipher /e [folder or file name]". This will encrypt the selected file or folder using the default encryption algorithm.

Can I choose a specific encryption algorithm when using cmd/bat/vbscript codes?

Yes, you can specify the encryption algorithm to use by adding the "/a" parameter followed by the algorithm code. For example, to use AES 256-bit encryption, the command would be "cipher /e /a:AES256 [folder or file name]". You can find a list of available encryption algorithms by typing "cipher /?" in cmd.

How do I decrypt an encrypted file or folder using cmd/bat/vbscript codes?

To decrypt an encrypted file or folder, you can use the "cipher" command with the "/d" parameter. The syntax would be "cipher /d [folder or file name]". You will need to provide the password used for encryption.

Can I encrypt multiple files or folders at once using cmd/bat/vbscript codes?

Yes, you can encrypt multiple files or folders by including their names in the command, separated by a space. For example: "cipher /e [file1] [file2] [folder1] [folder2]".

How can I check the encryption status of a file or folder using cmd/bat/vbscript codes?

You can use the "cipher" command with the "/s" parameter to see the encryption status of a file or folder. This will show you if the file or folder is encrypted, decrypted, or partially encrypted.

Similar threads

Replies
16
Views
5K
Replies
20
Views
2K
Replies
1
Views
695
Replies
4
Views
1K
Replies
7
Views
2K
Replies
1
Views
1K
Replies
5
Views
1K
Back
Top