Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eskopp committed Nov 19, 2023
0 parents commit c9121e8
Show file tree
Hide file tree
Showing 23 changed files with 1,604 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Bug report
description: Report a bug or issue in the project.
labels: ['bug']
body:
- type: markdown
attributes:
value: |
<b>Thank you for reporting an issue. </b>
- type: textarea
id: steps
attributes:
label: Steps to reproduce the bug
description: Provide precise step-by-step instructions on how to reproduce the bug.
placeholder: |
1. Go to ...
2. Click on ...
3. ...
validations:
required: true
- type: textarea
id: expected
attributes:
label: What did you expect to happen?
validations:
required: true
- type: textarea
id: outcome
attributes:
label: What happened instead?
validations:
required: true
- type: input
attributes:
label: Operating system
description: Specify the operating system you are using when encountering the bug (e.g., Windows 11).
validations:
required: true
- type: input
attributes:
label: Java version (or alternate access method)
description: Specify the Java and version you are using (java --version). Otherwise, specify your access method (such as API).
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: |
Provide any additional information that will provide more context for the issue you are encountering.
Screenshots can be added by clicking this area and then pasting or dragging them in.
validations:
required: false

7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/other.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Other
about: Other issue or enhancement
title: ''
labels: ''
assignees: ''
---
94 changes: 94 additions & 0 deletions .github/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Java Crypt


## Install Java
The first thing to do is to install java. This works differently with each operating system. Here is the instruction for Ubuntu
```shell
sudo apt update -y
sudo apt-get install -y openjdk-17-jre
```

## Build Project
The commands for Java are platform independent. Therefore, it doesn't matter if you run it on Linux or Windows.

### 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
javac -Xlint:unchecked ./javacrypt/*.java
```


### 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
```

## Usage

### 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]
```

### 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.
```

### 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.
```


### 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.
```


### Copy Files
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.
```

## Program architecture
Here is the UML plan of the project.
<img src="./img/UML.png" alt="Java UML">

Binary file added .github/img/UML.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
daysUntilStale: 21
daysUntilClose: 7
exemptLabels:
- prospect
- foundational
- wanted
- bug
staleLabel: stale
markComment: >
There has been no activity on this issue for 2 years. It will be
automatically closed in 2 weeks.
If the issue is still relevant, please briefly explain (or remove the label).
Feel free to reopen at any time.
closeComment: false
33 changes: 33 additions & 0 deletions .github/workflows/makefile_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Linux Makefile

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Dos2Unix
run: |
sudo apt-get install dos2unix -y
sudo dos2unix makefile.sh
- name: run makefile
run: |
sudo sh makefile.sh
- name: Short test
run: |
java -jar JavaCrypt.jar
java -jar JavaCrypt.jar -genkeys
- name: Clean Up
run: |
rm -rf *.key
git clean -fX
28 changes: 28 additions & 0 deletions .github/workflows/makefile_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Windows Makefile

on:
push:
branches:
- main

jobs:
build:
runs-on: windows-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Run makefile
run: |
./makefile.cmd
- name: Short test
run: |
java -jar JavaCrypt.jar
java -jar JavaCrypt.jar -genkeys
- name: Clean Up
run: |
del *.key
git clean -fX
73 changes: 73 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: JavaCrypt Test

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
java: [8, 11, 16, 17, 18, 20]

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}


- name: Compiling the Java code
run: javac -Xlint:unchecked ./javacrypt/*.java

- name: Creating the JAR archive
run: jar cfm JavaCrypt.jar manifest.mf javacrypt/*.class

- name: Start Tool
run: java -jar JavaCrypt.jar

- name: Generate Keys
run: java -jar JavaCrypt.jar -genkeys priv.key pub.key

- name: create Test (clear) File
run: |
crypt_file="weather_report.txt"
if [ ! -e "$crypt_file" ]; then
echo "Dear readers, today's weather is best described as a blend of unpleasant dampness and ominous clouds." > "$crypt_file"
else
exit 1
fi
touch encrypt.txt
touch decrypt.txt
- name: encrypt file
run: java -jar JavaCrypt.jar -encrypt pub.key weather_report.txt encrypt.txt

- name: decrypt file
run: java -jar JavaCrypt.jar -decrypt priv.key encrypt.txt decrypt.txt

- name: compare files
run: |
datei1="decrypt.txt"
datei2="weather_report.txt"
cat $datei1
cat $datei2
if [ -e "$datei1" ] && [ -e "$datei2" ]; then
if ! cmp -s "$datei1" "$datei2"; then
exit 1
fi
fi
- name: Clean Up
run: |
rm -rf *.key
rm -rf *.txt
git clean -fX
Loading

0 comments on commit c9121e8

Please sign in to comment.