From 982d4f4745fb0a84e7bb742778f5fec9b337e009 Mon Sep 17 00:00:00 2001 From: Erik Skopp Date: Sun, 19 Nov 2023 16:14:14 +0100 Subject: [PATCH] fix Readme --- .github/Readme.md | 106 +++++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 39 deletions(-) diff --git a/.github/Readme.md b/.github/Readme.md index 970740d..da73be1 100644 --- a/.github/Readme.md +++ b/.github/Readme.md @@ -2,16 +2,28 @@ ## Install Java -The first thing to do is to install java. This works differently with each operating system. Here is the instruction for Ubuntu +The first thing to do is to install java. This works differently with each operating system. ```shell -sudo apt update -y -sudo apt-get install -y openjdk-17-jre +sudo apt update && sudo apt upgrade -y +sudo apt install -y coreutils default-jre default-jdk dos2unix ``` ## Build Project The commands for Java are platform independent. Therefore, it doesn't matter if you run it on Linux or Windows. -### Build Class +### Makefile +- Linux +```bash +dos2unix makefile.sh +sudo sh makefile.sh +``` +- Windows +```powershell +./makefile.cmd +``` + +### Self Build +#### Build Class The command ``javac -Xlint:unchecked ./javacrypt/*.java`` compiles all the Java files in the ``./javacrypt`` directory with the ``-Xlint:unchecked`` option to display warnings for unchecked operations. ```shell @@ -19,60 +31,38 @@ javac -Xlint:unchecked ./javacrypt/*.java ``` -### Build JAR-File +#### Build JAR-File The command ``jar cfm MyCrypt.jar ./makefile.txt javacrypt/*.class`` creates a JAR (Java Archive) file named ``MyCrypt.jar`` with the specified manifest file (``makefile.txt``) and includes all the class files (``*.class``) in the ``javacrypt`` directory. ```shell - jar cfm MyCrypt.jar manifest.txt javacrypt/*.class + jar cfm JavaCrypt.jar manifest.mf javacrypt/*.class ``` -## Usage +## Run JavaCrypt ### Start Programm ```shell -$ java -jar JavaCrypt.jar -Program 'MyCryptMain' -usage: - MyCryptMain -genkeys [priv_keyfile] [pub_keyfile] - MyCryptMain -encrypt [pub_keyfile] [ifile] [ofile] - MyCryptMain -decrypt [privkeyfile] [ifile] [ofile] - MyCryptMain -copy [dummyword] [ifile] [ofile] +java -jar JavaCrypt.jar ``` ### Generate Keys Before you can use the encryption, you need to generate it with keys. The keys are stored in binary form. Therefore, they cannot be opened with a normal editor. The public key is needed for encryption and the private key for decryption. ```shell -$ java -jar JavaCrypt.jar -genkeys -Class found : javacrypt.RunGenKeys -Package : package javacrypt -RunGenkeys -Private Schluesseldatei : priv.key -Oeffentliche Schluesseldatei : pub.key -Ende des Programms. +java -jar JavaCrypt.jar -genkeys ``` ### Encrypt Files For the encryption you need three files. A public key, the file to be encrypted and the output file. With the flag "-encrypt" and the correct specification of the files the file will be encrypted. ```shell -$ java -jar JavaCrypt.jar -encrypt ./pub.key text.txt test_encrypt.txt -Class found : javacrypt.RunEncrypt -Package : package javacrypt -RunEncrypt -Anzahl der uebertragenen Bytes=600 -Ende des Programms. +java -jar JavaCrypt.jar -encrypt ``` ### Decrypt Files For decryption, you need three files. A private key, the file to be decrypted and the output file. By the flag "-decrypt" and the correct specification of the files the file is decrypted. ```shell -$ java -jar JavaCrypt.jar -decrypt ./priv.key test_encrypt.txt test_decrypt.txt -Class found : javacrypt.RunDecrypt -Package : package javacrypt -RunDecrypt -Anzahl der uebertragenen Bytes=768 -Ende des Programms. +java -jar JavaCrypt.jar -decrypt ``` @@ -80,14 +70,52 @@ Ende des Programms. The copying of files is a function that has arisen more through the others. For this reason one must also specify a "dummy word". But it doesn't matter which string you enter, because it will be ignored. ```shell -$ java -jar JavaCrypt.jar -copy dummy text.txt text_copy.txt -Class found : javacrypt.RunCopy -Package : package javacrypt -RunCopy -Anzahl der uebertragenen Bytes=600 -Ende des Programms. +java -jar JavaCrypt.jar -copy dummy text.txt text_copy.txt +``` + +## Usage +```bash +➜ JavaCrypt git:(main) ✗ javac -Xlint:unchecked ./javacrypt/*.java + +➜ JavaCrypt git:(main) ✗ jar cfm JavaCrypt.jar manifest.mf javacrypt/*.class + +➜ JavaCrypt git:(main) ✗ java -jar JavaCrypt.jar +Program 'JavaCrypt' +Usage: + JavaCrypt -genkeys [priv_keyfile] [pub_keyfile] + JavaCrypt -encrypt [pub_keyfile] [ifile] [ofile] + JavaCrypt -decrypt [privkeyfile] [ifile] [ofile] + JavaCrypt -copy [dummyword] [ifile] [ofile] + + +➜ JavaCrypt git:(main) ✗ java -jar JavaCrypt.jar -genkeys priv.key pub.key +RunGenKeys +Private key file: /mnt/e/git_eskopp/JavaCrypt/priv.key +Public key file: /mnt/e/git_eskopp/JavaCrypt/pub.key +End of the program. + +➜ JavaCrypt git:(main) ✗ echo "Hello World" > test.txt + +➜ JavaCrypt git:(main) ✗ java -jar JavaCrypt.jar -encrypt pub.key test.txt test_encrypt.txt +RunEncrypt +Number of bytes transferred: 128 +End of the program. + +➜ JavaCrypt git:(main) ✗ cat test_encrypt.txt +"^X/�L��[^EaD���^?�(�@^]��^_�-��WV�>^A�ǚ�M^_i�[��4�w�^P���e���^Tћ +96�����^X���� �C'�/^Z^X���������=�G��oe`.�^Xۙ�f�D�W����d|Cb ^]w���^Zy��f" + + +➜ JavaCrypt git:(main) ✗ java -jar JavaCrypt.jar -decrypt priv.key test_encrypt.txt test_decrypt.txt +RunDecrypt +Number of bytes transferred: 128 +End of the program. + +➜ JavaCrypt git:(main) ✗ cat test_decrypt.txt +Hello World ``` + ## Program architecture Here is the UML plan of the project. Java UML