Encrypting file or folders via cmd/bat/vbscript codes

  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    File
Click For Summary
SUMMARY

This discussion focuses on encrypting files and folders using command line tools, specifically .vbs, cmd, and .bat scripts on Windows 10. Users can utilize cryptography libraries like OpenSSL or built-in features of tools such as WinZip for password protection. The conversation emphasizes the importance of using trusted encryption methods rather than custom algorithms, as well as the need for secure password handling practices. Additionally, it highlights the use of binary reading methods and AES encryption for various file types including .jpg, .txt, .pdf, and more.

PREREQUISITES
  • Basic understanding of Windows command line operations
  • Familiarity with scripting languages such as VBScript (.vbs)
  • Knowledge of cryptography concepts, specifically AES encryption
  • Experience with file handling in programming, particularly binary file operations
NEXT STEPS
  • Research how to implement AES encryption in VBScript
  • Explore command line tools for file compression and encryption, such as 7-Zip
  • Learn about secure password management practices for command line scripts
  • Investigate methods for recursively accessing and encrypting files in subdirectories
USEFUL FOR

This discussion is beneficial for developers, system administrators, and anyone interested in securing personal data through scripting and command line tools on Windows 10.

Arman777
Insights Author
Gold Member
Messages
2,163
Reaction score
191
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
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   Reactions: FactChecker
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   Reactions: hmmm27, sysprog, FactChecker and 1 other person
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   Reactions: berkeman
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.
 
After some edits, the thread is re-opened.
 
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.
 
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.
 
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.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
7K
  • · Replies 20 ·
Replies
20
Views
4K
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
3
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K