Skip to content

Commit 9635b53

Browse files
committed
Complete steganography project
0 parents  commit 9635b53

File tree

23 files changed

+1104
-0
lines changed

23 files changed

+1104
-0
lines changed

.clang-format

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Generated from CLion C/C++ Code Style settings
2+
---
3+
Language: Cpp
4+
BasedOnStyle: Google
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignOperands: true
8+
AlignTrailingComments: false
9+
AlwaysBreakTemplateDeclarations: Yes
10+
BraceWrapping:
11+
AfterCaseLabel: false
12+
AfterClass: false
13+
AfterControlStatement: false
14+
AfterEnum: false
15+
AfterFunction: false
16+
AfterNamespace: false
17+
AfterStruct: false
18+
AfterUnion: false
19+
AfterExternBlock: false
20+
BeforeCatch: false
21+
BeforeElse: false
22+
BeforeLambdaBody: false
23+
BeforeWhile: false
24+
SplitEmptyFunction: true
25+
SplitEmptyRecord: true
26+
SplitEmptyNamespace: true
27+
BreakBeforeBraces: Custom
28+
BreakConstructorInitializers: AfterColon
29+
BreakConstructorInitializersBeforeComma: false
30+
ColumnLimit: 120
31+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
32+
IncludeCategories:
33+
- Regex: '^<.*'
34+
Priority: 1
35+
- Regex: '^".*'
36+
Priority: 2
37+
- Regex: '.*'
38+
Priority: 3
39+
IncludeIsMainRegex: '([-_](test|unittest))?$'
40+
IndentCaseLabels: true
41+
InsertNewlineAtEOF: true
42+
MacroBlockBegin: ''
43+
MacroBlockEnd: ''
44+
MaxEmptyLinesToKeep: 2
45+
NamespaceIndentation: All
46+
SpaceAfterCStyleCast: true
47+
SpaceAfterTemplateKeyword: false
48+
SpaceBeforeRangeBasedForLoopColon: false
49+
SpaceInEmptyParentheses: false
50+
SpacesInAngles: false
51+
SpacesInConditionalStatement: false
52+
SpacesInCStyleCastParentheses: false
53+
SpacesInParentheses: false
54+
TabWidth: 2
55+
...

.gitignore

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/cmake,clion,c++
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=cmake,clion,c++
3+
4+
### C++ ###
5+
# Prerequisites
6+
*.d
7+
8+
# Compiled Object files
9+
*.slo
10+
*.lo
11+
*.o
12+
*.obj
13+
14+
# Precompiled Headers
15+
*.gch
16+
*.pch
17+
18+
# Compiled Dynamic libraries
19+
*.so
20+
*.dylib
21+
*.dll
22+
23+
# Fortran module files
24+
*.mod
25+
*.smod
26+
27+
# Compiled Static libraries
28+
*.lai
29+
*.la
30+
*.a
31+
*.lib
32+
33+
# Executables
34+
*.exe
35+
*.out
36+
*.app
37+
38+
### CLion ###
39+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
40+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
41+
42+
# User-specific stuff
43+
.idea/**/workspace.xml
44+
.idea/**/tasks.xml
45+
.idea/**/usage.statistics.xml
46+
.idea/**/dictionaries
47+
.idea/**/shelf
48+
.idea/**/material_theme_project_new.xml
49+
50+
# AWS User-specific
51+
.idea/**/aws.xml
52+
.idea/**/discord.xml
53+
54+
# Generated files
55+
.idea/**/contentModel.xml
56+
57+
# Sensitive or high-churn files
58+
.idea/**/dataSources/
59+
.idea/**/dataSources.ids
60+
.idea/**/dataSources.local.xml
61+
.idea/**/sqlDataSources.xml
62+
.idea/**/dynamic.xml
63+
.idea/**/uiDesigner.xml
64+
.idea/**/dbnavigator.xml
65+
66+
# Gradle
67+
.idea/**/gradle.xml
68+
.idea/**/libraries
69+
70+
# Gradle and Maven with auto-import
71+
# When using Gradle or Maven with auto-import, you should exclude module files,
72+
# since they will be recreated, and may cause churn. Uncomment if using
73+
# auto-import.
74+
# .idea/artifacts
75+
# .idea/compiler.xml
76+
# .idea/jarRepositories.xml
77+
# .idea/modules.xml
78+
# .idea/*.iml
79+
# .idea/modules
80+
# *.iml
81+
# *.ipr
82+
83+
# CMake
84+
cmake-build-*/
85+
86+
# Mongo Explorer plugin
87+
.idea/**/mongoSettings.xml
88+
89+
# File-based project format
90+
*.iws
91+
92+
# IntelliJ
93+
out/
94+
95+
# mpeltonen/sbt-idea plugin
96+
.idea_modules/
97+
98+
# JIRA plugin
99+
atlassian-ide-plugin.xml
100+
101+
# Cursive Clojure plugin
102+
.idea/replstate.xml
103+
104+
# SonarLint plugin
105+
.idea/sonarlint/
106+
107+
# Crashlytics plugin (for Android Studio and IntelliJ)
108+
com_crashlytics_export_strings.xml
109+
crashlytics.properties
110+
crashlytics-build.properties
111+
fabric.properties
112+
113+
# Editor-based Rest Client
114+
.idea/httpRequests
115+
116+
# Android studio 3.1+ serialized cache file
117+
.idea/caches/build_file_checksums.ser
118+
119+
### CLion Patch ###
120+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
121+
122+
# *.iml
123+
# modules.xml
124+
# .idea/misc.xml
125+
# *.ipr
126+
127+
# Sonarlint plugin
128+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
129+
.idea/**/sonarlint/
130+
131+
# SonarQube Plugin
132+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
133+
.idea/**/sonarIssues.xml
134+
135+
# Markdown Navigator plugin
136+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
137+
.idea/**/markdown-navigator.xml
138+
.idea/**/markdown-navigator-enh.xml
139+
.idea/**/markdown-navigator/
140+
141+
# Cache file creation bug
142+
# See https://youtrack.jetbrains.com/issue/JBR-2257
143+
.idea/$CACHE_FILE$
144+
145+
# CodeStream plugin
146+
# https://plugins.jetbrains.com/plugin/12206-codestream
147+
.idea/codestream.xml
148+
149+
# Azure Toolkit for IntelliJ plugin
150+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
151+
.idea/**/azureSettings.xml
152+
153+
### CMake ###
154+
CMakeLists.txt.user
155+
CMakeCache.txt
156+
CMakeFiles
157+
CMakeScripts
158+
Testing
159+
Makefile
160+
cmake_install.cmake
161+
install_manifest.txt
162+
compile_commands.json
163+
CTestTestfile.cmake
164+
_deps
165+
166+
### CMake Patch ###
167+
# External projects
168+
*-prefix/
169+
170+
# End of https://www.toptal.com/developers/gitignore/api/cmake,clion,c++

CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.29)
2+
project(steganography_cli)
3+
4+
set(CMAKE_CXX_STANDARD 20)
5+
6+
include(FetchContent)
7+
8+
FetchContent_Declare(
9+
fmt
10+
GIT_REPOSITORY https://github.com/fmtlib/fmt
11+
GIT_TAG 11.0.2)
12+
FetchContent_MakeAvailable(fmt)
13+
14+
include_directories(include)
15+
add_executable(steganography_cli src/main.cpp
16+
include/image/formats/ppm.h
17+
include/image/formats/bmp.h
18+
include/image/formats/base.h
19+
src/image/formats/base.cpp
20+
include/image/pixel.h
21+
src/image/formats/ppm.cpp
22+
src/image/formats/bmp.cpp
23+
src/image/pixel.cpp
24+
src/image/formats/base.cpp
25+
include/image/helpers.h
26+
src/image/helpers.cpp
27+
include/file/helpers.h
28+
src/file/helpers.cpp
29+
include/cli/args.h
30+
src/cli/args.cpp
31+
include/cli/helpers.h
32+
src/cli/helpers.cpp
33+
)
34+
target_link_libraries(steganography_cli fmt::fmt)

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2025 Daniel Olczyk
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
![C++](https://img.shields.io/badge/C%2B%2B-00599C?style=for-the-badge&logo=c%2B%2B&logoColor=white)
2+
![CMake](https://img.shields.io/badge/CMake-064F8C?style=for-the-badge&logo=cmake&logoColor=white)
3+
![GitHub repo size](https://img.shields.io/github/repo-size/MRmlik12/steganography-cpp?style=for-the-badge)
4+
![GitHub](https://img.shields.io/github/license/MRmlik12/steganography-cpp?style=for-the-badge)
5+
6+
# Steganography in C++
7+
8+
CLI tool to hide and extract text in images using LSB technique. Created for PJC (Programming in C/C++) course at PJAIT university.
9+
10+
## Features
11+
12+
- Hide text in image in .bmp and .ppm format
13+
- Extract text from image in .bmp and .ppm format
14+
- Check if the text can be hidden in the image
15+
- File information (size, format, last modified date, resolution)
16+
17+
## Requirements
18+
19+
* CMake 3.29 or higher
20+
* GCC or clang compiler with C++20 support
21+
* Make
22+
23+
## Building
24+
25+
```bash
26+
$ cmake . .
27+
$ cmake --build .
28+
```
29+
30+
## Usage
31+
32+
```bash
33+
$ ./steganography_cli
34+
Użycie: ./steganography-cli [opcje]
35+
-h Wyświetla dostępne opcje programu
36+
-i / --include "<ścieżka_do_pliku>" Wyświetla informacje o pliku
37+
-c / --check "<ścieżka_do_pliku>" "<wiadomość>" Sprawdza, czy jest możliwe ukrycie wiadomości w pliku
38+
-e / --encrypt "<ścieżka_do_pliku>" "<wiadomość>" Ukrywa wiadomość w pliku graficznym (Wspierane formaty to .bmp i .ppm)
39+
-d / --decrypt "<ścieżka_do_pliku>" Odszyfrowuje plik (Wspierane formaty to .bmp i .ppm)
40+
```

include/cli/args.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#ifndef CLI_ARGS_H
2+
#define CLI_ARGS_H
3+
4+
#include <filesystem>
5+
#include <functional>
6+
#include <map>
7+
8+
class CliArgs {
9+
private:
10+
bool info;
11+
bool encrypt;
12+
bool decrypt;
13+
bool check;
14+
bool help;
15+
16+
std::string path;
17+
std::string message;
18+
19+
auto setInfo(bool state) -> void;
20+
21+
auto setEncrypt(bool state) -> void;
22+
23+
auto setDecrypt(bool state) -> void;
24+
25+
auto setCheck(bool state) -> void;
26+
27+
auto setHelp(bool state) -> void;
28+
29+
auto getParameters() -> std::map<std::string, std::function<void(bool)>>;
30+
31+
public:
32+
CliArgs() = default;
33+
34+
~CliArgs() = delete;
35+
36+
auto static parse(const char *args[]) -> CliArgs *;
37+
38+
auto needsInformation() const -> bool;
39+
40+
auto needsDisplayHelp() const -> bool;
41+
42+
auto needsEncrypt() const -> bool;
43+
44+
auto needsDecrypt() const -> bool;
45+
46+
auto needsCheck() const -> bool;
47+
48+
auto getMessage() const -> std::string;
49+
50+
auto getPath() const -> std::filesystem::path;
51+
};
52+
53+
#endif

include/cli/helpers.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef CLI_HELPERS_H
2+
#define CLI_HELPERS_H
3+
4+
#include "cli/args.h"
5+
6+
auto printHelp() -> void;
7+
auto tryCreateCliArgs(const char *argv[]) -> CliArgs*;
8+
9+
#endif

include/consts.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef CONSTS_H
2+
#define CONSTS_H
3+
4+
constexpr char *SUPPORTED_FILES[2] = {".bmp", ".ppm"};
5+
constexpr unsigned char BMP_HEADERS[2] = {0x42, 0x4D};
6+
constexpr unsigned char PPM_HEADERS[2] = {0x50, 0x36};
7+
constexpr char MAX_MESSAGE_SIZE = 64;
8+
9+
#endif

include/file/helpers.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef FILE_HELPERS_H
2+
#define FILE_HELPERS_H
3+
4+
#include <filesystem>
5+
6+
enum FilePermissions { READ, WRITE, READ_WRITE };
7+
8+
auto getFileSizeInMB(const std::filesystem::path &path) -> double;
9+
auto getLastModifiedDateTime(const std::filesystem::path &path) -> std::string;
10+
auto getExtensionSupportedByProgram(const std::filesystem::path &path) -> bool;
11+
auto verifyFilePermissions(const std::filesystem::path &path, FilePermissions permission) -> bool;
12+
13+
#endif

0 commit comments

Comments
 (0)