Encrypting file or folders via cmd/bat/vbscript codes

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

Discussion Overview

The discussion revolves around methods for encrypting files and folders using command line interfaces, specifically through .vbs, cmd, or .bat scripts. Participants explore various approaches, tools, and considerations for implementing encryption on personal data, particularly in the context of Windows 10.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • Some participants inquire about the feasibility of encrypting personal data using basic scripting methods like .vbs, cmd, or .bat commands.
  • One suggestion involves using a cryptography library, such as OpenSSL, while noting that there are simpler solutions available.
  • Another participant proposes using WinZip or similar software to create password-protected ZIP files as an alternative method of encryption.
  • There is a mention of using a fingerprint encrypted USB flash drive as a means of secure key storage.
  • One participant expresses interest in implementing encryption for various file types, including .txt and Word documents, and discusses reading and encrypting data using Python functions.
  • A later reply mentions the use of XOR commands in VBS as a potential method for encryption.
  • Concerns are raised about the security of custom encryption algorithms, with a recommendation to use trusted tools instead.
  • Another participant describes a method involving reading files as binary and encrypting the data using AES, indicating that they have developed a code capable of encrypting multiple file types.
  • Discussion includes the need to access subdirectories to encrypt files systematically.

Areas of Agreement / Disagreement

Participants express a variety of methods and tools for encryption, with no clear consensus on a single approach. Multiple competing views and techniques remain present in the discussion.

Contextual Notes

Participants highlight limitations regarding password handling in command line tools, noting that passwords cannot be passed as arguments or via pipes, which may affect the implementation of encryption scripts.

Who May Find This Useful

Individuals interested in file encryption methods, particularly those looking to use scripting languages on Windows systems, may find the discussion relevant.

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