Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
5c83312
branch to delete
lucasTrswl Dec 17, 2024
26ba4f5
Vigenere Algo development
lucasTrswl Dec 17, 2024
8196d48
feat : Ajout des classes MD5 et RC4 pour le hachage et le chiffrement
Bilnaa Dec 17, 2024
ccec8c6
feat : Ajout de tests unitaires pour les classes MD5 et RC4
Bilnaa Dec 17, 2024
78321e2
feat : Ajout d'un workflow GitHub Actions pour exécuter des tests JUnit
Bilnaa Dec 17, 2024
4ae0356
Add LFSR class
Roronoatii Dec 17, 2024
c44cebe
feat : Ajout de la branche 'develop' au workflow GitHub Actions pour …
Bilnaa Dec 17, 2024
e6d4041
feat : Mise à jour des branches surveillées dans le workflow GitHub A…
Bilnaa Dec 17, 2024
210a056
Fix parameter name
Roronoatii Dec 17, 2024
9afe3dc
feat : Amélioration du workflow GitHub Actions pour la compilation et…
Bilnaa Dec 17, 2024
7aad04b
feat : Ajout de JUnit4 comme bibliothèque de test et création d'un te…
Bilnaa Dec 17, 2024
81ffd42
revert : back to init state
Bilnaa Dec 17, 2024
93f8d69
chore : make the methods public for tests and future implementations …
Bilnaa Dec 17, 2024
5201013
chore : added tests for the lfsr
Bilnaa Dec 17, 2024
7c87667
chore : usage of english is mandatory
Bilnaa Dec 17, 2024
d1c9cf6
Merge pull request #2 from Bilnaa/feat/story-9-10_md5-rc4-implementation
Bilnaa Dec 17, 2024
0cee02e
Merge pull request #3 from Bilnaa/feat/Story7_LFSR
Bilnaa Dec 17, 2024
77c32ce
feat : Ajout des classes MD5 et RC4 pour le hachage et le chiffrement
Bilnaa Dec 17, 2024
4c4bf57
feat : Ajout de tests unitaires pour les classes MD5 et RC4
Bilnaa Dec 17, 2024
ed831b0
feat : Ajout d'un workflow GitHub Actions pour exécuter des tests JUnit
Bilnaa Dec 17, 2024
1e26be0
feat : Ajout de la branche 'develop' au workflow GitHub Actions pour …
Bilnaa Dec 17, 2024
f61c5f7
feat : Mise à jour des branches surveillées dans le workflow GitHub A…
Bilnaa Dec 17, 2024
ac99612
feat : Amélioration du workflow GitHub Actions pour la compilation et…
Bilnaa Dec 17, 2024
287233b
chore : usage of english is mandatory
Bilnaa Dec 17, 2024
7f50b9d
Add LFSR class
Roronoatii Dec 17, 2024
e7b96f2
Fix parameter name
Roronoatii Dec 17, 2024
fa34c84
revert : back to init state
Bilnaa Dec 17, 2024
af3d29b
chore : make the methods public for tests and future implementations …
Bilnaa Dec 17, 2024
4c71f04
chore : added tests for the lfsr
Bilnaa Dec 17, 2024
c1d2294
chore : move file to classes folder
Bilnaa Dec 17, 2024
3b1408a
refactor Vigenere Algo in Classes
lucasTrswl Dec 18, 2024
4e97654
Add MD5 and SHA256 classes that extend hash Class
Roronoatii Dec 18, 2024
51f10ef
Add tests for hash sha256
Roronoatii Dec 18, 2024
3fc8825
Merge pull request #5 from Bilnaa/Story11_SHA256
Bilnaa Dec 18, 2024
b4333c8
feat : added the enigma class with the Rotors, Reflector and Plugboar…
Bilnaa Dec 18, 2024
9d9eead
test : added the tests for the whole enigma package
Bilnaa Dec 18, 2024
0a48e50
VigenereAlgo tests
lucasTrswl Dec 18, 2024
fa8e338
chore : correct hard coded values
Bilnaa Dec 18, 2024
d6fe930
Add MD5 and SHA256 classes that extend hash Class
Roronoatii Dec 18, 2024
9f36b09
Add tests for hash sha256
Roronoatii Dec 18, 2024
9cb3221
Merge pull request #4 from Bilnaa/feat/Story5_VigenereAlgo
Bilnaa Dec 18, 2024
469c3a2
docs : added comments for the whole enigma package
Bilnaa Dec 18, 2024
469c480
ROT(X) algorithm with tests
lucasTrswl Dec 18, 2024
659bb4a
Merge pull request #7 from Bilnaa/feat/Story3-4_ROT(X)Algorithm
lucasTrswl Dec 18, 2024
44465e4
Merge pull request #6 from Bilnaa/feat/Story8_Enigma
Roronoatii Dec 18, 2024
b9e0b2a
add comments to ROTX Tests
lucasTrswl Dec 18, 2024
5f60c94
Merge pull request #8 from Bilnaa/feat/Story3-4_ROT(X)Algorithm
lucasTrswl Dec 18, 2024
1845676
feat : add polyb square encrytion method
snowsuit321 Dec 18, 2024
eb20d6d
main menu development In Progress
lucasTrswl Dec 18, 2024
ea5321a
Merge pull request #9 from Bilnaa/feat_Story1_MainMenu
lucasTrswl Dec 18, 2024
2a9d6ba
Main Menu bdd setup
lucasTrswl Dec 18, 2024
0a2d669
feat : add polyb square decryption method
snowsuit321 Dec 18, 2024
ceff994
Add Menu
Roronoatii Dec 18, 2024
fd6d7cf
chore : added the libs for video stegano
Bilnaa Dec 18, 2024
7848547
feat : added the classes for steganography for the encoding and decod…
Bilnaa Dec 18, 2024
5c159de
test : added unit tests for image and text steganography encoding and…
Bilnaa Dec 18, 2024
14b3a58
TODO : fix implementation of video steganography this change is here …
Bilnaa Dec 18, 2024
83f6134
fix unsaved
Roronoatii Dec 19, 2024
6b74bc6
fix unsaved changed
Roronoatii Dec 19, 2024
9c02b8e
chore : update jdk version
Bilnaa Dec 19, 2024
e2639c5
chore : added gson to the deps
Bilnaa Dec 19, 2024
5c0d070
chore : moved the test files to the assets folder
Bilnaa Dec 19, 2024
920aaf7
Merge pull request #10 from Bilnaa/feat_Story1_MainMenu
Bilnaa Dec 19, 2024
f6df1a7
feat : add documentation and use of string builders to return encrypt…
snowsuit321 Dec 19, 2024
985891a
feat : add initial tests for PolybSquareEncrypter
snowsuit321 Dec 19, 2024
e64171c
chore : delete duplicates
Bilnaa Dec 19, 2024
064c6de
chore : use the right path of file in the tests
Bilnaa Dec 19, 2024
33b00c7
Merge branch 'develop' into feat/Story15_Steganography
Bilnaa Dec 19, 2024
632f817
chore : added the libs for video stegano
Bilnaa Dec 18, 2024
2b815a2
chore : delete duplicates in deps file
Bilnaa Dec 19, 2024
9510fda
chore : added the javacv-platform to the ci for the video stetaganogr…
Bilnaa Dec 19, 2024
96973b4
chore : added ffmpeg
Bilnaa Dec 19, 2024
3fbaebe
chore: added the missing libs
Bilnaa Dec 19, 2024
b087ec4
fix : yml fixed
Bilnaa Dec 19, 2024
bc09763
fix : test image steganography when image is null
Bilnaa Dec 19, 2024
75e7f98
chore : added more robustness checks for the text stegano
Bilnaa Dec 19, 2024
67877f8
chore : added more robustness checks for the text stegano
Bilnaa Dec 19, 2024
257d486
Merge pull request #12 from Bilnaa/feat/Story15_Steganography
Bilnaa Dec 19, 2024
edd9339
Merge pull request #13 from Bilnaa/feat/Story6_PolybSquare
Bilnaa Dec 19, 2024
b4721b0
Help Menu to guide the user through the program
lucasTrswl Dec 19, 2024
b3c1a28
Merge pull request #14 from Bilnaa/feat/Story2_HelpMenu
Roronoatii Dec 19, 2024
de4e5a7
Add databases cipher
Roronoatii Dec 20, 2024
c1b26fb
Add multi encryption
Roronoatii Dec 20, 2024
733f4d9
fix : make the menu go back
Bilnaa Dec 20, 2024
9ab4b1d
chore : added decode image with an already existing image
Bilnaa Dec 20, 2024
f47753a
Merge pull request #16 from Bilnaa/feat/Story12_AlgorithmChoiceRefacto
Bilnaa Dec 20, 2024
117de6c
Refacto sitemanager and databasesmanager
Roronoatii Dec 20, 2024
2bb4b2a
Merge pull request #17 from Bilnaa/feat/Story12_AlgorithmChoiceRefacto
Bilnaa Dec 20, 2024
75e5f84
chore : added build info for building
Bilnaa Dec 20, 2024
5794ef3
feat : added animation to the menu
Bilnaa Dec 20, 2024
c922a8a
chore : the main program executes menu
Bilnaa Dec 20, 2024
e8f8eb8
salt and pepper
lucasTrswl Dec 20, 2024
7d8e4d5
Merge branch 'develop' into feat/Story20_Sel_Poivre_HMAC
Bilnaa Dec 20, 2024
c180639
Merge pull request #19 from Bilnaa/feat/Story20_Sel_Poivre_HMAC
Bilnaa Dec 20, 2024
77b05c6
Merge branch 'develop' into feat/menu-animation
Bilnaa Dec 20, 2024
cfdf784
Merge pull request #20 from Bilnaa/feat/menu-animation
Bilnaa Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Java CI with JUnit Tests

on:
push:
branches: [ "main", "develop" ]
pull_request:
branches: [ "main", "develop" ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 23
uses: actions/setup-java@v3
with:
java-version: '23'
distribution: 'temurin'

- name: Show Project Structure
run: |
echo "Current directory:"
pwd
echo "Directory contents:"
ls -R

- name: Download Dependencies
run: |
mkdir -p lib
wget https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar -P lib/
wget https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar -P lib/
wget https://repo1.maven.org/maven2/com/google/code/gson/gson/2.11.0/gson-2.11.0.jar -P lib/
wget https://repo1.maven.org/maven2/org/bytedeco/javacv/1.5.11/javacv-1.5.11.jar -P lib/
wget https://repo1.maven.org/maven2/org/bytedeco/javacpp/1.5.11/javacpp-1.5.11.jar -P lib/
wget https://repo1.maven.org/maven2/org/bytedeco/ffmpeg/7.1-1.5.11/ffmpeg-7.1-1.5.11.jar -P lib/
wget https://repo1.maven.org/maven2/org/bytedeco/ffmpeg/7.1-1.5.11/ffmpeg-7.1-1.5.11-linux-x86_64.jar -P lib/
wget https://repo1.maven.org/maven2/org/bytedeco/javacpp-platform/1.5.11/javacpp-platform-1.5.11.jar -P lib/


- name: Compile
run: |
mkdir -p out
# Liste et compile les fichiers principaux
MAIN_FILES=$(find src/Classes -name "*.java")
if [ ! -z "$MAIN_FILES" ]; then
echo "Compiling main files:"
echo "$MAIN_FILES"
javac -cp "lib/*" -d out $MAIN_FILES
else
echo "No main files found"
fi

# Liste et compile les fichiers de test
TEST_FILES=$(find src/Tests -name "*.java")
if [ ! -z "$TEST_FILES" ]; then
echo "Compiling test files:"
echo "$TEST_FILES"
javac -cp "out:lib/*" -d out $TEST_FILES
else
echo "No test files found"
fi

- name: Run tests
run: |
# Trouve et exécute tous les tests
TEST_CLASSES=$(find out/Tests -name "*Test.class" | sed 's/out\///' | sed 's/\.class$//' | tr '/' '.')
if [ ! -z "$TEST_CLASSES" ]; then
echo "Running test classes:"
echo "$TEST_CLASSES"
java -cp "out:lib/*" org.junit.runner.JUnitCore $TEST_CLASSES
else
echo "No test classes found"
fi

- name: Generate Test Report
if: always()
run: |
echo "# Test Results" > test-report.md
echo "\`\`\`" >> test-report.md
TEST_CLASSES=$(find out/Tests -name "*Test.class" | sed 's/out\///' | sed 's/\.class$//' | tr '/' '.')
if [ ! -z "$TEST_CLASSES" ]; then
java -cp "out:lib/*" org.junit.runner.JUnitCore $TEST_CLASSES >> test-report.md 2>&1 || true
else
echo "No test classes found" >> test-report.md
fi
echo "\`\`\`" >> test-report.md

- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: test-report
path: test-report.md
152 changes: 152 additions & 0 deletions .idea/artifacts/ByteWarden_jar.xml

Large diffs are not rendered by default.

284 changes: 284 additions & 0 deletions .idea/libraries/bytedeco_javacv_platform.xml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .idea/libraries/fasterxml_jackson_core_databind.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/libraries/google_code_gson.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ByteWarden.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="google.code.gson" level="project" />
<orderEntry type="library" name="bytedeco.javacv.platform" level="project" />
<orderEntry type="library" name="fasterxml.jackson.core.databind" level="project" />
</component>
</module>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![Tests](https://github.com/Bilnaa/ByteWarden/actions/workflows/tests.yml/badge.svg)
18 changes: 18 additions & 0 deletions databases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"llucas": {
"name": "llucas",
"hashPassword": "eebc1115b82aea1ee598f927e19500c75d2e318eaa9d83fa5a7513e26dea608b",
"encryptionMap": {
"RotX": "12"
},
"salt": "NTNcG1Mv\u002604K"
},
"test": {
"name": "test",
"hashPassword": "6b3fcb519f1dac8495538eed6bf3963faf7d7a6762d6789869a2cb51a9bca91d",
"encryptionMap": {
"RotX": "12"
},
"salt": "sP5s3cWwMsOX"
}
}
9 changes: 9 additions & 0 deletions llucas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"eufqe": [
{
"bmeeiadp": "rlrqlr",
"eufqZmyq": "kagfgnq",
"geqdzmyq": "lplp"
}
]
}
3 changes: 3 additions & 0 deletions pepper.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"pepper": "jesuisunpoivre"
}
124 changes: 124 additions & 0 deletions src/Classes/DatabasesManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package Classes;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

public class DatabasesManager {
private final File databasesFile;
private final Map<String, Database> databases;
private final Sha256 sha256 = new Sha256();

public DatabasesManager(File databasesFile) {
this.databasesFile = databasesFile;
this.databases = loadDatabases() != null ? loadDatabases() : new HashMap<>();
}
//Verify the hashed password with the password entered by the user
public boolean verifyDatabase(String dbName, String password) {
if (!databases.containsKey(dbName)) return false;
Database database = databases.get(dbName);
String pepper = readPepperFromJson("pepper.json");

String hashedPassword = sha256.calculateHash(database.getSalt() + password + pepper);
return database.getHashPassword().equals(hashedPassword);
}
//create database object with user inputs
public void createDatabase(String dbName, String password, Map<String, String> encryptionMap) {
if (databases.containsKey(dbName)) {
throw new IllegalArgumentException("Database already exists.");
}
String pepper = readPepperFromJson("pepper.json");
String salt = PasswordUtils.generateRandomPassword(12);
String hashedPassword = sha256.calculateHash(salt + password + pepper);
Database newDatabase = new Database(dbName, hashedPassword, encryptionMap, salt);
databases.put(dbName, newDatabase);
saveDatabases();
}

private String readPepperFromJson(String filePath) {
ObjectMapper objectMapper = new ObjectMapper();
try {
Map<String, String> jsonMap = objectMapper.readValue(new File(filePath), Map.class);
return jsonMap.get("pepper");
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
private Map<String, Database> loadDatabases() {
if (!databasesFile.exists()) return new HashMap<>();
try (FileReader reader = new FileReader(databasesFile)) {
Gson gson = new Gson();
Type type = new TypeToken<Map<String, Database>>() {}.getType();
return gson.fromJson(reader, type);
} catch (IOException e) {
e.printStackTrace();
return new HashMap<>();
}
}


private void saveDatabases() {
try (FileWriter writer = new FileWriter(databasesFile)) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
gson.toJson(databases, writer);
} catch (IOException e) {
e.printStackTrace();
}
}

// class database to make the database manager easy to use
public static class Database {
private final String name;
private final String hashPassword;
private final Map<String, String> encryptionMap;
private final String salt;
public Database(String name, String hashPassword, Map<String, String> encryptionMap, String salt) {
this.name = name;
this.hashPassword = hashPassword;
this.encryptionMap = encryptionMap;
this.salt = salt;
}

public String getName() {
return name;
}

public String getHashPassword() {
return hashPassword;
}

public Map<String, String> getEncryptionMap() {
return encryptionMap;
}
public String getSalt(){
return salt;
}


}
//method to get the encryption map for the encryption and decryption during the database user selection
public Map<String, String> getEncryptionMap(String dbName) {
if (!databases.containsKey(dbName)) { // if the database name doesn't exist
throw new IllegalArgumentException("Database does not exist: " + dbName);
}
try (FileReader reader = new FileReader(databasesFile)) {
Gson gson = new Gson();
Map<String, Map<String, Object>> allDatabases = gson.fromJson(reader, Map.class); //get all the databases info from databases.json
Map<String, Object> dbData = allDatabases.get(dbName); //get the wanted database
return (Map<String, String>) dbData.get("encryptionMap"); // get all the encryption methods from the current database
} catch (IOException e) {
throw new RuntimeException("Failed to read databases file.", e);
}
}

}
52 changes: 52 additions & 0 deletions src/Classes/Enigma/Enigma.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package Classes.Enigma;

public class Enigma {
private Rotors rotors = new Rotors(); // Rotors component
private Reflector reflector = new Reflector(); // Reflector component
private Plugboard plugboard = new Plugboard(); // Plugboard component

public Enigma() {
}

public Enigma(Rotors rotors, Reflector reflector, Plugboard plugboard) {
this.rotors = rotors;
this.reflector = reflector;
this.plugboard = plugboard;
}

public Rotors getRotors() {
return rotors; // Return the rotors component
}

public Reflector getReflector() {
return reflector; // Return the reflector component
}

public Plugboard getPlugboard() {
return plugboard; // Return the plugboard component
}

public String encrypt(String message) {
StringBuilder encryptedMessage = new StringBuilder();
for (char c : message.toCharArray()) {
if (Character.isLetter(c)) {
c = Character.toUpperCase(c); // Convert to uppercase
c = plugboard.swap(c); // Swap using plugboard
c = rotors.rotate(c); // Rotate through rotors
c = reflector.reflect(c); // Reflect the character
c = rotors.rotateBack(c); // Rotate back through rotors
c = plugboard.swap(c); // Swap using plugboard again
if (Character.isLowerCase(message.charAt(encryptedMessage.length()))) {
c = Character.toLowerCase(c); // Convert back to lowercase if needed
}
}
encryptedMessage.append(c); // Append the encrypted character
}
return encryptedMessage.toString();
}

public String decrypt(String message) {
rotors.resetToInitialPosition(); // Reset rotors to initial positions
return encrypt(message); // Decrypt by re-encrypting
}
}
40 changes: 40 additions & 0 deletions src/Classes/Enigma/Plugboard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package Classes.Enigma;

import java.util.HashMap;
import java.util.Map;

public class Plugboard {
private Map<Character, Character> connections; // Map to store the letter pairs for swapping

public Plugboard() {
connections = new HashMap<>(); // Initialize the connections map
}

/**
* Connects two letters in the plugboard
* @param a First letter to connect
* @param b Second letter to connect
* @throws IllegalArgumentException if letters are already connected
*/
public void connect(char a, char b) {
a = Character.toUpperCase(a); // Convert to uppercase for consistency
b = Character.toUpperCase(b);

if (connections.containsKey(a) || connections.containsKey(b)) {
throw new IllegalArgumentException("Letters are already connected"); // Check if letters are already connected
}

connections.put(a, b); // Create bidirectional connection
connections.put(b, a);
}

/**
* Swaps a letter according to plugboard connections
* @param c Letter to swap
* @return Swapped letter if connection exists, original letter otherwise
*/
public char swap(char c) {
c = Character.toUpperCase(c); // Convert to uppercase for consistency
return connections.getOrDefault(c, c); // Swap the letter if connection exists
}
}
Loading
Loading