Introduction: Command Line Encryption on Windows
Cryptography is used in many applications these days. It allows for your internet usage and passwords used to log into banking and email sites to be masked from those with bad intentions.
This will guide you through installing Cygwin on your Windows machine, setting up an environment, using the environment to compile code, and use executables created to accomplish what they are designed to do. In particular, the code for this executable encrypts and decrypts plain text files. The encryption scheme used here is what is known as the Vigenere cipher.
The groundwork of installing Cygwin and its various packages gives you the ability to do many things. There are packages that let you host webpages from your system. Others let you develop graphical interfaces that can do any number of things like pressing buttons or blurring a picture. Google is a great starting place for additional options and steps to use Cygwin and its many packages.
This should take you less than an hour to complete.
For this, you will need:
- A windows computer. Please know if it is a 32 or 64 bit machine. Microsoft's site, https://support.microsoft.com/en-us/help/15056/wi... explains how to figure this out.
- Administrator privileges on that machine
- An unzipper such as WinZip installed. Another option is 7-Zip. WinZip Can be downloaded at http://www.winzip.com/win/en/index.htm.
- Internet Connection
- A plain text file you would like to encrypt
Step 1: Download Cygwin's Installer
To download Cygwin's installer:
- Navigate to "https://www.cygwin.com"
- Select "Install Cygwin" from the colored bar on the left hand side of the screen
- Select the "setup-x86*.exe" form the section that matches the version of your Windows machine. Options are 32 and 64 bit.
- This will initiate a download of the installer.
- The download should complete in less than a minute. At 12 Mbps, the download time is a fraction of a second.
Step 2: Install Cygwin
Once installer is downloaded:
- Open a Windows Explorer window where it was downloaded. Typically Downloads.
- Double click on the most recent download with the Cygwin logo, the first image tied to this step, next to the file name that looks like "setup-x86*.exe."
- Cygwin's setup window, the second image, will appear. Select next to get started.
If you are having issues finding the installer,
- Open your browser's downloads list, and there will be a "Show in folder" link. The last image gives Chrome's downloads list. This link will take you to its location.
Step 3: Setting the Settings
For this step, the installer will learn where to store packages it downloads, from where to download and the type of connection it will use.
- Select install from internet on the first page and hit next.
- Leave the default settings on this page and hit next. Unless you know what you are doing (i.e installing for one user).
- Leave "Local Package Directory" alone and hit next. Again, unless you know what you are doing feel free to change things.
- Select your Internet connection. It should be direct, unless you know otherwise. Select next.
- Now, for choosing a download site, use sites that contain "cygwin.mirror" or those that contain ".edu" near the top of the list and hit next. It might take a few seconds to load the packages list.
Step 4: Selecting Packages
- There are a lot of packages available. You however only need 2 plus their dependencies. The two needed are gcc-g++ and make.
To install the compiler, for these purposes gcc-g++, do the following:
- Select "Full" from the drop down menu at the top of the window.
- In the search bar, type "gcc-g++."
- Now from the narrowed list, click on the "Skip" for the package row that contains "gcc-g++: GNU Compiler Collection (C++)."
- A series of numbers will replace skip. They are the version numbers. The first one that comes up works fine.
The second package will assist in compiling source files.
- From the drop down menu, select "Category."
- In the search bar, type "make."
- This narrows the size of the category tree for this package selection.
- Click on the plus next to the "Devel" category.
- Click on the skip for the package that contains "make: the GNU version of the 'make' utility."
- Now hit next.
- A "Dependencies" window will show up. These are additional packages that are required to use the packages selected above.
- Select next again. This will begin the download and install of the packages. A progress window will appear showing status of download and install processes.
Download and install of the packages will take some time, no longer than quarter of an hour. So move onto the next step.
Step 5: Obtaining Source Code
To obtain the source code for the encryption being used, complete the following steps.
- Download and unzip attached zip file using WinZip, or your chosen unzipper.
- To unzip using WinZip, double click on the zip file, and select the "1-click Unzip" button. This will, per its namesake, unzip the file and dump into a folder.
- The folder created above is opened in a Windows Explorer window.
For now, leave that window open. It will be used later.
Step 6: Generating Executables
Once Cygwin's "Create Icons" window shows signalling that the install has completed proceed with the rest of this step.
- Select create a desktop shortcut. If not, you will have difficulty launching Cygwin.
- Launch Cygwin.
To compile the code, a few more steps need to be completed. First off, Cygwin is not "sitting" where it can see the code you extracted in the previous step. So we need to "move" it so the files are visible. To do so:
- Type "cd " into the Cygwin window. Be sure to include the space after the "d"
- Drag and drop one of the files from the Windows Explorer window you left open into the Cygwin window.
- The second image shows what the Cygwin window will look like. The only difference is the folder names.
- Remove the name of the file that you dragged into the window from the end of the line. If there are quotation marksMAKE SURE you LEAVE the QUOTATION MARKS. EX. just "decrypt.cpp" will be removed from image above.
- Hit enter. Now Cygwin is able to use the files downloaded.
Lastly, move your plain text file into the Windows Explorer window you have open. This text file is what you will be encrypting.
Finally, it is possible to compile code. Do so by typing "make" and then hitting enter. If warnings appear, do not worry about them. Everything is fine.
Step 7: Encrypting and Decrypting
The results of the previous "make" command consists of 2 executables.
- One encrypts plain text files.
- The other decrypts encrypted plain text files.
To encrypt, you need the name of your plain text file (filename for this example), a keyword(KEYWORD), and Cygwin to be sitting where the executables and plain text file are sitting. This last requirement is accomplished in the previous step.
One thing to note about the keyword, it cannot contain symbols or numbers. It can only contain characters.
Encryption works like this. Type "./encrypt filename KEYWORD" and hit enter. The encrypted file will be stored in a file named after your original file name with the extension "et.txt." The et stands for encrypted text.
To decrypt: simply type "./decrypt filename.et.txt KEYWORD" and hit enter. Make sure to use the correct keyword. Otherwise the file produced will contain gibberish.
Step 8: Completion
You can now send this secret to a friend and, given they have the password, read what you sent.
Cygwin can be used for many other actions. You can use it to batch edit may files, search for files that have specific words on your computer and many others.
To find how to do above google "action using Cygwin." Action needs to be replaced with what you want to do. Many people post on the internet how to do amazing things.
We have a be nice policy.
Please be positive and constructive.