Using OpenSSL for File Encryption and Decryption
Introduction
This report details the steps taken to encrypt and decrypt a file using OpenSSL on a Mac terminal. The
primary goal is to ensure data security through encryption and verify successful decryption by comparing
the decrypted file with the original.
Tools and Environment
Operating System: macOS
Tool: OpenSSL
File: Project2.txt located in /Users/mustafadukureh/Library/Mobile
Documents/com~apple~TextEdit/Documents/
Steps and Commands
1. Getting Started
a. Start the OpenSSL command line:
openssl
(Optional) Explore available commands:
- List all commands:
openssl list -commands
- List cipher commands:
openssl list -cipher-commands
- List digest commands:
openssl list -digest-commands
b. Use the help command to learn more about OpenSSL:
openssl help, this is what you see when you enter the command.
2. Performance of OpenSSL
a. Run a speed test on the PC platform:
openssl speed
b. Comparing results
3. Encrypting the File
a. Encrypt the file using various algorithms:
- AES-128 CBC:
- AES-256 CTR:
- DES:
4. Decrypting the Encrypted Files
To decrypt the files, use the corresponding decryption commands:
a. AES-128 CBC:
b. AES-256 CTR:
c. DES:
5. Encrypting and Decrypting a File for Exchange
a. Encrypt the file with AES-256 CBC:
openssl enc -aes-256-cbc -in "/Users/mustafadukureh/Library/Mobile
Documents/com~apple~TextEdit/Documents/Project2.txt" -out encrypted_file.bin -k "8865075"
b. Decrypt the file:
openssl enc -d -aes-256-cbc -in encrypted_file.bin -out decrypted_Project2.txt -k "9876777"
6. Verifying Decryption
To confirm that the file has been successfully decrypted, compare the contents of the original file and the
decrypted file:
a. View the original file:
cat "/Users/mustafadukureh/Library/Mobile Documents/com~apple~TextEdit/Documents/Project2.txt"
b. View the decrypted file:
cat decrypted_Project2.txt
c. Compare the files:
diff "/Users/mustafadukureh/Library/Mobile Documents/com~apple~TextEdit/Documents/Project2.txt"
decrypted_Project2.txt
If the `diff` command produces no output, it indicates that the original and decrypted files are identical,
confirming successful decryption. If there are differences, they will be displayed, indicating a potential
issue with the decryption process or the password used.
Conclusion
The process detailed above successfully demonstrates the use of OpenSSL to encrypt and decrypt files on
a Mac terminal. By following these steps, one can ensure data security and verify the integrity of the
decrypted data by comparing it with the original file.