Encrypting file or folders via cmd/bat/vbscript codes

  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    File
AI Thread Summary
The discussion focuses on encrypting personal data using basic scripting methods like .vbs, cmd, or .bat on Windows 10. Participants highlight the need for a cryptography library, with OpenSSL mentioned as a potential tool. Various solutions are suggested, including using WinZip for password-protected ZIP files and employing fingerprint-encrypted USB drives for secure key storage. The importance of avoiding custom encryption algorithms is emphasized, as they may be easily compromised. A method involving binary file reading and AES encryption is proposed, allowing for the encryption of multiple file types such as .jpg, .txt, .pdf, and more. The conversation also touches on the necessity of accessing subdirectories to encrypt files systematically. Overall, the thread provides insights into practical approaches for file encryption while maintaining security.
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 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 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 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.
 
Back
Top