0% found this document useful (0 votes)
6 views

ProjectReport

The document discusses the significance of multimedia steganography in securing data transmission, highlighting its applications across various fields such as medical, agriculture, and defense. It reviews existing techniques and challenges in steganography, emphasizing the need for a balance between data hiding capacity and perceptual quality while addressing security concerns against detection. The analysis includes a literature survey, feasibility studies, and risk assessments related to steganographic methods, underscoring the importance of robust security measures and ethical considerations in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

ProjectReport

The document discusses the significance of multimedia steganography in securing data transmission, highlighting its applications across various fields such as medical, agriculture, and defense. It reviews existing techniques and challenges in steganography, emphasizing the need for a balance between data hiding capacity and perceptual quality while addressing security concerns against detection. The analysis includes a literature survey, feasibility studies, and risk assessments related to steganographic methods, underscoring the importance of robust security measures and ethical considerations in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

ABSTRACT

According to the latest estimates, 328.77 million terabytes of data are created
each day. Protecting and securing the transmission of this data is the key tothe
creation of a better digital world. Data is the pollution problem of the information
age, and protecting privacy is the environmental challenge. In the present
decade, images have become a valuable source of information. They play an
essential role in every field whether it be medical, agriculture, defense or
education. Over the past few years, steganography has received a lot of attention
for passing military sensitive details. The information is passed generally via
image steganography. With the increase in amount to data to hide, other
multimedia formats are gaining popularity too. Secured communication on
sensitive information between two parties need to consider information security
as necessity. Steganography and cryptography can be used to enhance the
information security. Cryptography discloses the availability of information,
whereas steganography hides the availability of information so that no other than
the two communicating parties can recognize it. With advancement in internet
applications the information mainly consists of text, audio, image, and video type
of information. This project provides a detailed analysis and methodology for
Multimedia based steganography of information. Also, we tend to discuss the
available methods and techniques for multimedia steganography and their
performances.
CONTENT

Chapter
TITLE Page No.
No
ABSTRACT vi

LIST OF FIGURES viii

1 INTRODUCTION 9-10

2 LITERATURE SURVEY 10-14

2.1 Inferences from Literature Survey 12-13

2.2 Open problems in Existing System 14

3 REQUIREMENTS ANALYSIS 15-18


3.1 Feasibility Studies/Risk Analysis of the Project 15-17
3.2 Software Requirements Specification Document 17-18
4 DESCRIPTION OF PROPOSED SYSTEM 19-31

4.1 Selected Methodology or process model 22-25

4.2 Architecture / Overall Design of Proposed System 26

Description of Software for Implementation and 27-28


4.3
Testing plan of the Proposed Model/System
5 IMPLEMENTATION DETAILS 32-35

5.1 Installing Spring Boot Application 32-33

5.2 Deploying Spring Boot Application 33-35

6 RESULTS & DISCUSSION 35-37


7 CONCLUSION 38

REFERENCES 39-40

APPENDIX
A SOURCE CODE 40-65

B RESEARCH PAPER 66-76

C CERTIFICATE 77
LIST OF FIGURES

FIGURE FIGURE NAME PAGE


NO. NO.

1.1 Evolution of Steganography 10

4.1 Image Steganography 21

4.2 Audio Steganography 21

4.3 Video Steganography 22

4.1.1 Chaotic mapping evaluation criteria equations 23

4.1.2 Chaotic mapping evaluation criteria equations 25

4.1.3 Flowchart of Encryption Process 25

4.1.4 Flowchart of Decryption Process 25

4.2 System Architecture 27

4.3.1 Comparative Study of Various types of Chaotic Mapping Methods 29

4.4.1 Welcome Page of Application when started 35

4.4.2 Human.jpeg 36

4.4.3 Animal.jpeg 36

4.4.4 Pic2in1.jpeg 36

4.4.5 Encryption Webpage 32

4.4.6 Decryption Webpage 32

4.4.7 Spring Application Started 32

5.1 Deployment Code 31

5.1.1 Application Configuration 32

5.2.1 Directory Structure of Project 33

5.2.2 Image Steganography Implementation 34

5.2.3 Audio Steganography Implementation 34

5.2.4 Video Steganography Implementation 34

Table 1 Study of Various types of Chaotic Mapping Methods 29

viii
CHAPTER 1
INTRODUCTION

Steganography is the practice of concealing one piece of information within another


in such a way that it is difficult to detect or decipher. It is often used to hide the existence
of a secret message within an innocuous carrier medium, such as text, images, audio,
or video files. The word "steganography" is derived from the Greek words "steganos"
meaning "covered" and "graphia" meaning "writing" essentiallydescribing the act of
hiding information within another form of data.
Multimedia steganography, specifically, focuses on concealing information within
multimedia files like images, audio, and video. This branch of steganography has
gained significant attention due to the proliferation of digital multimedia content on the
internet. Here's a brief introduction to steganography and multimedia steganography:

Image Steganography: In image steganography, secret data is embedded within an


image file. Common techniques include modifying the least significant bits of the pixel
values or altering the frequency components of the image in a way that is imperceptible
to the human eye.

Audio Steganography: In audio steganography, secret data is hidden within an audio


file, often inaudibly. Techniques may involve modifying the amplitude or frequency
components of audio signals to encode the information.

Video Steganography: Video steganography hides data within video files. It can be
more challenging than other forms, as it involves both spatial and temporal data.
Techniques often rely on modifying frames or altering specific video characteristics.

Network steganography is the youngest branch of information hiding. It is a fast-


developing field: recent years have resulted in multiple new information hiding
methods, which can be exploited in various types of networks. The exploitation of
protocols belonging to the Open Systems Interconnection (OSI) reference model [59]
is the essence of network steganography. This family of methods may utilize one or

9
more protocols simultaneously or the relationships between them – relying on the
modification of their intrinsic properties for the embedding of steganograms.

Lately, another steganographic method – TranSteg (Transcoding Steganography),


intended for a broad class of multimedia and real-time applications, like IP telephony,
has been proposed. TranSteg bases on the general idea of transcoding (lossy
compression) of the voice data from a higher bit rate codec, and thus greater voice
payload size, to a lower bit rate codec with smaller voice payload size. This occurs with
the least possible degradation in voice quality. In other words, compression of the overt
data is utilized to make space for the steganogram in the payload field. The achieved
steganographic bandwidth is as high as 32 kbit/s.

Figure 1.1 Evolution of Steganography

In conclusion, steganography, especially multimedia steganography, plays a crucial


role in information security, privacy, and copyright protection. It allows for the covert
transmission of data while maintaining the appearance of the carrier medium, making
it an essential tool in various fields, including cybersecurity and digital content
management, offering covert communication capabilities, enhancing data security,
safeguarding privacy, and facilitating copyright protection measures. Its widespread
adoption underscores its importance in addressing various security and privacy
challenges.

10
CHAPTER 2
LITERATURE SURVEY

This problem statement has been extensively studied over the past 5 years by
researchers and automotive companies in a bid to create a solution, and all their
solutions vary from analyzing various patterns of distractive habits to analyzing health
vitals of the driver.

The work of Dr. Alluri Harika et al [1] introduced a steganography image imaging
application which is based on the Advanced Encryption Standard (AES) and random
bit technique. The AES technique is used to encrypt the secret message and the
random bit technique is used to hide the encrypted message in the image.

Multimedia steganography involves various techniques, including Least Significant Bit


(LSB) embedding, frequency domain methods (e.g., Discrete Cosine Transform), and
spread spectrum techniques. Several papers delve into the analysis and enhancement
of these techniques, such as "Steganography Using Reversible Texture Synthesis" by
Thien et al [2].

Research in this area focuses on improving the security of steganography and


developing more robust detection methods. "Current Challenges in Steganography
for Digital Images" by Naveed et al. [3] is an example of a paper discussing the
challenges and security issues in image steganography.

Studies aim to increase the information hiding capacity while maintaining perceptual
quality. Papers like "Adaptive Steganography with Minimization of the Impact on the
Carrier Image" by Dumitrescu et al. [4] explore ways to achieve this balance.

Steganography isn't limited to images; it extends to audio and video. Research papers
such as "Audio Steganography: A Comprehensive Review" by Alzahrani and Almutairi
[5] cover methods and challenges in audio steganography.

Deep learning techniques have also been applied to improve steganography and
steganalysis. "Towards Unsupervised Deep Steganography" by Xu et al. [6] discusses

11
using convolutional neural networks for steganography.

Steganalysis is the art of detecting hidden data. Papers like "Steganalysis of


Multimedia: A Comprehensive Review" by Hussain et al. [7] provide insights into
steganalysis methods and challenges.

Some papers explore practical applications of multimedia steganography, such as "A


Survey on Steganography Techniques for Digital Images" by Singh and Khanna [8],
which discusses the use of steganography in medical imaging.

Hardware acceleration, particularly using GPUs, has been a focus in recent research.
"Parallel Steganography and Steganalysis on Graphics Hardware" by Bianchi and Piva
[9] is an example of work in this area.

2.1 INFERENCES FROM LITREATURE SURVEY

Inferences drawn from a literature survey of multimedia steganography can provide


insights into the current state of research and highlight trends and challenges within
the field. Here are some common inferences that can be made based on a literature
survey of multimedia steganography:

Diverse and Evolving Techniques: Multimedia steganography encompasses a wide


range of techniques, from traditional LSB-based methods to advanced frequency
domain and deep learning approaches. Researchers continue to develop and refine
these techniques to achieve better hiding capacity and imperceptibility.

Security and Detection Remain Critical: Ensuring the security of hidden information and
developing robust steganalysis methods are ongoing challenges. Researchers are
working on both sides of the spectrum, devising more secure embedding techniques
and more effective detection methods.

Balancing Capacity and Quality: Striking a balance between increasing data hiding
capacity and maintaining the perceptual quality of multimedia files is a significant
concern. Research is focused on methods that hide larger amounts of data while

12
minimizing the visual or auditory impact on the carrier file.

Extension to Audio and Video: Steganography is not limited to images; it extends to


audio and video data. Research has increasingly explored techniques and challenges
specific to audio and video steganography.

Emergence of Deep Learning: Deep learning techniques have made their way into
multimedia steganography, with convolutional neural networks and other modelsbeing
applied to enhance both steganography and steganalysis.

Steganalysis Advances: Steganalysis, the process of detecting hidden data, is a


growing area of research. Researchers are developing more sophisticated methods
to detect hidden content.

Applications Beyond Privacy: Steganography has applications beyond privacy and


security. Some studies explore the use of steganography in medical imaging, copyright
protection, and data hiding for various practical purposes.

Hardware Acceleration: The use of hardware acceleration, particularly GPUs, is


gaining traction in multimedia steganography research. This can significantly speed
up the embedding and detection processes.

Ethical and Legal Considerations: Researchers and scholars are increasingly


addressing the ethical and legal aspects of steganography. Discussions on responsible
usage and potential legal implications are growing in importance.

Challenges and Future Directions: A recurring theme in the literature is the


identification of challenges and the proposal of future research directions. Researchers
are continuously looking for ways to improve the field and address its limitations.

In conclusion, a literature survey of multimedia steganography reveals a dynamic and


evolving field that incorporates various techniques, security concerns, and emerging
trends. It highlights the importance of balancing data hiding capacity with perceptual
quality, the ongoing battle between steganography and steganalysis, and the

13
exploration of new application areas. Moreover, it underscores the ethical and legal
considerations that researchers and practitioners need to address as steganography
continues to advance.

2.2 OPEN PROBLEMS IN EXISTING SYSTEM

Capacity vs. Security Trade-off: Balancing the amount of hidden information (capacity)
with the level of security against detection is a fundamental challenge in
steganography. Increasing capacity often leads to a higher chance of detection.

Robustness to Attacks: Steganography techniques should be able to withstand various


forms of attacks, such as compression, filtering, noise addition, and other common
image processing operations.

Security Against Advanced Statistical Attacks: Steganalysis techniques continue to


improve, utilizing advanced statistical and machine learning methods. Designing
steganographic algorithms that are robust against these sophisticated attacks remains
an ongoing challenge.

Payload Integrity and Reliability: Ensuring that the hidden information is reliably
extracted without corruption, even in the presence of minor distortions or lossy
compression, is a critical concern.

Multimedia Type Agnosticism: Many steganography techniques are designed for


specific types of media (e.g., images, audio, video). Developing methods that can work
seamlessly across different types of media is an open problem.

Adaptive and Dynamic Embedding Strategies: Designing steganographic techniques


that adaptively adjust the embedding process based on the content and context of
the cover media is a challenging problem.

Reducing Detectable Artifacts: Even with sophisticated steganalysis techniques,


certain steganographic methods can still leave detectable artifacts. Research is
focused on minimizing these artifacts to enhance stealthiness.

14
Quantifying Security and Detectability: Developing metrics to quantitatively measure
the level of security provided by a steganographic algorithm, as well as the detectability
by potential adversaries, remains a significant challenge.

15
CHAPTER 3

REQUIREMENT ANALYSIS

3.1 FEASIBILITY STUDIES/RISK ANALYSIS OF THE PROJECT

Risk analysis in steganography involves identifying, assessing, and mitigating potential


risks and vulnerabilities associated with the use of steganographic techniques. These
risks can have significant implications for both security and privacy. Here's a
breakdown of risk analysis in steganography:

Detection Risk: The primary risk in steganography is the potential detection of hidden
information by adversaries or steganalysis techniques. Detection risks could lead to
the exposure of sensitive data or the compromise of covert communication.

Misuse Risk: There is a risk that steganography techniques can be misused for
malicious purposes, such as concealing malware, distributing illegal content, or
bypassing security controls.

Data Loss Risk: When data is embedded within multimedia files, there's a risk of data
loss or corruption during the embedding and extraction processes. If the embedded
data is critical, its loss could have significant consequences.

Inadequate Security Risk: If steganographic methods are not implemented securely,


there is a risk that the hidden data can be easily extracted or compromised. Weak
security measures can lead to unauthorized access to concealed information.

Privacy Risk: In cases where steganography is used to protect privacy, there's a risk
that the hidden data may be exposed, leading to privacy breaches.

Likelihood: Evaluate the likelihood of each identified risk occurring. Factors that
contribute to likelihood include the sophistication of potential adversaries, the strength
of the steganographic method, and the prevalence of steganalysis techniques.

16
Impact: Assess the potential impact of each risk. Consider the consequences of
detection, misuse, data loss, or privacy breaches.

Vulnerability Analysis: Identify vulnerabilities within the steganographic system itself.


Vulnerabilities may include weak encryption, inadequate key management, or poor
implementation of steganographic algorithms.

Steganographic Technique Selection: Choose steganographic techniques that strike


an appropriate balance between capacity (amount of hidden data) and imperceptibility
(invisibility of alterations).

Secure Key Management: Implement robust key management practices to protect the
steganographic keys. This includes key generation, distribution, and storagestrategies
to prevent unauthorized access.

Use of Encryption: Combine steganography with encryption to provide an additional


layer of security. Encrypt the data before embedding it within multimedia files, ensuring
that even if detected, the hidden information remains protected.

Regular Updates and Monitoring: Continuously update steganographic tools and


techniques to stay ahead of evolving steganalysis methods. Regularly monitor the
security landscape for emerging threats.

Compliance with Ethical and Legal Standards: Ensure that the use of steganography
aligns with ethical and legal standards. Avoid activities that may lead to legal
consequences or ethical violations.

Documentation: Document the identified risks, risk assessments, and mitigation


strategies. This documentation should be shared with relevant stakeholders, including
those responsible for system security and decision-makers.

Training and Awareness: Provide training and awareness programs to individuals who
use steganography for legitimate purposes. This can help prevent misuse and enhance
security.

17
In conclusion, risk analysis in steganography is crucial for understanding and
addressing the potential threats and vulnerabilities associated with hidden data. By
systematically identifying, assessing, and mitigating risks, organizations and
individuals can make informed decisions about the use of steganography and ensure
the security and privacy of their data.

3.2 SOFTWARE REQUIREMENTS SPECIFICATION DOCUMENT

Multimedia steganography applications, which involve hiding data within audio, image,
or video files, may have slightly higher hardware requirements compared to general
steganography software, as multimedia files can be larger and require more processing
power. Here are the typical hardware requirements for running multimedia
steganography applications:

Processor (CPU): A multi-core processor with a clock speed of at least 2 GHz is


recommended. More powerful CPUs may be necessary for processing large
multimedia files or using advanced steganographic techniques.

Memory (RAM): 8GB or more of RAM is recommended for working with multimedia
files and steganography applications. Larger files or complex steganography methods
may benefit from more RAM.

Storage: Adequate storage space for multimedia files is necessary. SSDs are preferred
for faster read and write operations. Free space should accommodate the original
multimedia files, the steganography software, and any output files.

Graphics Processing Unit (GPU): While most multimedia steganography software


doesn't heavily rely on GPUs, certain advanced techniques, such as deep learning-
based steganography, may take advantage of GPU acceleration.

Operating System: Ensure that the multimedia steganography software you plan to use
is compatible with your operating system (e.g., Windows, macOS, or Linux).

18
Display: A standard computer monitor is sufficient for interacting with multimedia
steganography applications.

Sound Card (for audio steganography): If you're working with audio steganography, a
sound card with good audio input/output capabilities may be beneficial.

Internet Connection: An internet connection may be required for downloading and


updating multimedia steganography software.

Remember that the specific requirements can vary depending on the multimedia
steganography application and the complexity of the techniques you plan to use.

19
CHAPTER 4

DESCRIPTION OF PROPOSED SYSTEM

The proposed system in this project signifies a groundbreaking departure from


conventional methods for multimedia steganography, introducing an innovative and data-
driven approach that harnesses advanced technology and encryption/decryption
methodologies.

Text Steganography: The data is concealed within the text. The key knowledge of this
system is concealed behind the nth character in a phrase of the substance of the
document. There are several techniques in a text document to conceal data. They are as
follows: Format Based Method and Random and Statistical Method.

A new approach of text Steganography using ASCII values, this project aims to maximize
the usage capacity (text capability) in text Steganography. A new technique has been
proposed to encrypt the text or content inside the images by using pixel values and ASCII
values. Merging and dividing procedure is the heart of this method and gives the result.
In this technique they give more importance to pixel values. Unlike other techniques, this
model can embed or encrypt all 255 ASCII characters, this approach accessible only for
lossless text formats. The proposed algorithm clients can hide more measures of
information without altering the size of the cover picture. It implies changes reflected are
almost insignificant. This project’s limitation is to improve the efficiency of the
steganographic algorithm for better performance. We suggest a modern methodology of
format-based content Steganography, by utilizing the approach of two content or
steganography approaches that are line-shifting and character or word-shifting strategies
with a copy protection method. Mask the details or material in binary or digitized type
rather than character format by utilizing the above methods and less than one bit is hidden
in of line of cover text, so this approach has a strong hidden ability and less distortion in
the cover text is provided by this process.

Image Steganography: Image Steganography conceals details by selecting the cover


media or object as an image. In image Steganography, pixels qualities are considered. In
digital Steganography to encode information, images are commonly used as a cover
source because there are several bits present in digital image representation.

20
Fig 4.1: Image Steganography

Audio Steganography: In this strategy, the secret content is embedded in digitized or


binary audio. This result in small changes to the data gives solutions to audio
steganography which is available in the binary classification of the audio file. This includes
the embedding of audio files with data. This approach hides the sound files in mp3, au,
and wav, using specific audio Steganography methods. There are multiple techniques of
Audio Steganography. These techniques are as follows: Spread Spectrum, Low Bit
Encoding and Phase Coding.

Fig 4.2: Audio Steganography

Video Steganography: This is a method of concealing content in binary or digital video


format. Video (consists of a set of images) is usually used as the cover file for embedding
the contents. Typically, by using (DCT) i.e., discrete cosine transform algorithm modify
the values (9.667 to 10) that are used to mask the material in each entity of the images
in the video that the human eye cannot identify or locate. In video

21
Steganography the formats used are MP4 and MPE are used. In all of these approaches
the main motive is to conceal a secret message in another cover item. This may not be
able to guess the presence of information inside cover media. It is necessary to apply
the proper decoding method to retrieve the information.

Fig 4.3: Video Steganography

4.1 SELECTED METHODOLOGY OR PROCESS MODEL

Investigated Chaotic Maps: Chaotic systems are very sensitive to initial conditions also
chaotic systems has positive Lyapunov exponent which leads orbital instability.
Moreover, ergodicity property of chaotic systems is also used as a leveraging factor for
hiding information or generating unpredictable random sequences.
The some of the well-known chaotic mapping methods used in this study are:

22
• Logistics Map formula is given at Eq. (1)
• Tent Map formula is given at Eq. (2)
• Quadratic Map formula is given at Eq. (3)
• Bernoulli Map formula is given at Eq. (4)
• Sine Map formula is given at Eq. (5)
• Chebyshev Maps formula is given at Eq.(6)

Fig 4.1.1: Chaotic mapping methods equations

As it could be observed from given chaotic map equations are all effected by the previous
states. Therefore, those maps are sensitive to initial conditions also guessing the next
outcome of the map is difficult unless the initial conditions are known.

Evaluation Criteria: The authors of the study have determined the invisibility, load capacity
and robustness criteria against steganalysis and attacks. These their metric is used to
assess the steganographic systems. In their work at statistical indeterminacy is also
accepted as requirement.

Main evaluation criteria are defined below:

Imperceptibility- The Imperceptibility or in other word invisibility of hidden secret message


is the cardinal and fundamental requirement. When the changes are noticed in the
picture, the steganographic algorithm becomes void. Generally, is measured by

23
the quality of the stego image one important metric is PSNR (peak signal noise ratio).

Security- the hidden message should be secure even if stego image is identified. This is
generally obtained incorporating encryption scheme before embedding inside the cover
image. Chaotic systems are employed in this study to achieve and obtain a layer of
security since message will be hidden in different location, retrieving of the original text
will be hard even without encryption.

Payload capacity– it is defined as the amount secret message which that can be
unnoticeable embedded in a digital media. The amount of message should not cause
distortion of in the cover image. Bit Per Pixel rate can be used to measure, In this study
it is aimed to investigate the effects of different type of chaotic maps on the
imperceptibility property.

In order to evaluate aforementioned metrics and also assess quality of the stego image
Entropy, Correlation analysis, MSE (mean squared error) and PSRN (Peak Signal Noise
Ratio) are calculated. Equations form (7) to (10) are the given evaluation metrics:

Fig 4.1.2: Chaotic mapping evaluation criteria equations

24
Figure 4.1.3 Flowchart of Encryption Process

Figure 4.1.4 Flowchart of Decryption Process

Proposed Model and Evaluations: In the conventional LSB steganography, just LSB bit of
the carrier image is changed with the secret message bit. At first Secret message is
preprocessed as a bit vector. Secret message embedding location in the cover image is
selected by Chaotic maps. At this study only blue channel of the carrier image has been
alter. Chaotic maps are used to pick a Algorithm of the proposed methodology is given
below:

Algorithm 1

25
Algorithm for Embedding Message
Inputs: Cover image C, Message M, Keys Arrays: Coefficients and initial starting
point of Chaotic Maps Obtain Gzip of the Message M -> ZM
LIST ZM: Message Possible Locations
LIST : Cover Image Possible Locations TEMP:
Outputs: Stego Image

1- For j:0 to ZM
2- location=Generate Random Locations in the LIST ZM using Chaotic Map
3- Assign LIST ZM[location] message to TEMP
4- For i:0 to 7
5- Generate Random locations in the LIST using Chaotic Map
6- Remove the selected location from the LIST
7- Take mod 3 of Chaotic Location to Find the embedding channel
//0 Red, 1 Green, 2 Blue Channel
8- EMBED The LSB of the selected channel of the selected pixel with the
TEMP[i] bit
9- End For
10- Remove the selected ZM[location] from the LISTZM
11- End For
12- Return Stego Image

4.2 ARCHITECTURE / OVERALL DESIGN OF PROPOSED SYSTEM

The system architecture of a multimedia steganography application is a well- structured


framework composed of several interconnected components, each with specific roles and
responsibilities. The steganographic engine lies at the core, implementing various
techniques for embedding and extracting data within multimedia files, ensuring that the
original content remains visually or audibly intact. The multimedia file handler reads and
writes these files, and the optional encryption and error correction components may be
utilized to secure and maintain data integrity. Metadata management preserves metadata
consistency, and format compatibility components ensure compatibility with various file
formats. User preferences and settings, along with an output viewer/player, offer
customization options and the ability to review the modified multimedia content.
26
Fig 4.2: System Architecture

4.3 DESCRIPTION OF SOFTWARE FOR IMPLEMENTATION AND TESTING PLAN


OF THE PROPOSED MODEL/SYSTEM

The software for implementing and testing the proposed model/system for
encryption/decryption using above methodology plays a pivotal role in the project's
success.

Testing software using Java typically involves using various testing frameworks and
libraries to ensure the quality and reliability of Java applications. Here are some common
approaches and tools for testing software in Java:

JUnit: JUnit is one of the most popular Java testing frameworks for writing and running
unit tests. It allows you to define test cases, assert expected outcomes, and automate
27
the testing process.

TestNG: TestNG is another widely used testing framework that provides more advanced
features compared to JUnit. It supports various testing strategies, including unit testing,
integration testing, and end-to-end testing.

Selenium: Selenium is a popular open-source framework for automating web application


testing. You can use Java to write Selenium tests to interact with web elements and
validate web application behavior.

Mockito: Mockito is a Java mocking framework that helps you create mock objects for
testing. It's useful for isolating the code under test and simulating interactions with
dependencies.

Cucumber: Cucumber is a behavior-driven development (BDD) framework that allows


you to write tests in a human-readable format. It's often used for acceptance and
integration testing of Java applications.

Test frameworks in Java IDEs: Integrated Development Environments (IDEs) like Eclipse
and IntelliJ IDEA have built-in support for running and debugging Java tests. You can
create and execute test cases directly within your IDE.

Continuous Integration (CI) Tools: CI tools like Jenkins, Travis CI, and CircleCI can
be integrated with your Java projects to automate the testing process, run tests on each
code commit, and generate reports.

Load Testing: For performance testing, tools like Apache JMeter can be used in
combination with Java to simulate and analyze the behavior of an application under load.

Test Automation Frameworks: When building complex test suites or end-to-end tests, you
can create custom test automation frameworks in Java to manage and organize your
tests efficiently.

28
Table 1 Study of Various types of Chaotic Mapping Methods

IMAGE Bernoulli Logistic Quadratic Sine Tent


Original 0.15658549 0.1565854 0.0202527 0.1565374 0.1565495
Image 505 9505 7832 9505 05
Entropy
Carrier Image 0.15658588 0.1565857 0.1565863 0.1565840 0.1566147
Entropy 824 7751 0971 0236 99
Entropy - - - 0.0000004 -
Difference 0.00000039 0.0000054 0.0000088 92685 0.0001652
3196 07587 14662 948
Correlation 0.99999863 0.9999947 0.9999956 0.9999946 0.9999669
Difference 7121 65612 85202 34734 674
MSE 0.02014115 0.0203539 0.0202527 0.0203798 0.0201386
6250 30664 78320 09570 523
PNR 68.0898632 68.043230 68.066077 68.039974 68.090681
8575 01598 47841 85043 8610

Figure 4.3.1 Comparative Study of Various types of Chaotic Mapping Methods

29
CHAPTER 5
IMPLEMENTATION DETAILS

Spring Boot’s executable jars are ready-made for most popular cloud PaaS (Platform- as-
a-Service) providers. These providers tend to require that you “bring your owncontainer”.
They manage application processes (not Java applications specifically), so they need an
intermediary layer that adapts your application to the cloud’s notion of a running process.

Two popular cloud providers, Heroku and Cloud Foundry, employ a “buildpack” approach.
The buildpack wraps your deployed code in whatever is needed to start your
application. It might be a JDK and a call to java, an embedded web server, or a full-fledged
application server. A buildpack is pluggable, but ideally you should be able to get by with
as few customizations to it as possible. This reduces the footprint of functionality that is
not under your control. It minimizes divergence between development and production
environments.

Ideally, the application, like a Spring Boot executable jar, has everything that it needs to
run packaged within it.

By default, metadata about the running application as well as service connection


information is exposed to the application as environment variables (for example:
$VCAP_SERVICES). This architecture decision is due to Cloud Foundry’s polyglot (any
language and platform can be supported as a buildpack) nature. Process-scoped
environment variables are language agnostic.

Environment variables do not always make for the easiest API, so Spring Boot
automatically extracts them and flattens the data into properties that can be accessed
through Spring’s Environment abstraction, as shown in the below code:

All Cloud Foundry properties are prefixed with vcap. You can use vcap properties to
access application information (such as the public URL of the application) and service
information (such as database credentials).

30
Figure 5.1 Deployment Code

5.1 INSTALLING SPRING BOOT APPLICATION

In addition to running Spring Boot applications by using java -jar directly, it is also possible
to run them as systemd, init.d or Windows services. systemd is the successor of the
System V init system and is now being used by many modern Linux distributions. Spring
Boot applications can be launched by using systemd ‘service’ scripts. The user that runs
the application, the PID file, and the console log file are managed by systemd itself and
therefore must be configured by using appropriate fields in the ‘service’ script.

When executed as root, as is the case when root is being used to start an init.d service,
the default executable script runs the application as the user specified in the
RUN_AS_USER environment variable. When the environment variable is not set, the
user who owns the jar file is used instead. You should never run a Spring Boot application
as root, so RUN_AS_USER should never be root and your application’s jar file should
never be owned by root. Instead, create a specific user to run your application and set
the RUN_AS_USER environment variable or use chown to make it the owner of the jar
file.

If root is used to control the application’s service and you use a .conf file to customize its
startup, the .conf file is read and evaluated by the root user. It should be secured

31
accordingly. Use chmod so that the file can only be read by the owner and use chown to
make root the owner. It often makes sense to customize elements of the start script as it
is written into the jar file. For example, init.d scripts can provide a “description”. Since you
know the description up front (and it need not change), you may as well provide it when
the jar is generated.

With the exception of JARFILE and APP_NAME, the settings listed in the preceding
section can be configured by using a .conf file. The file is expected to be next to the jar
file and have the same name but suffixed with .conf rather than .jar. For example, ajar
named /var/myapp/myapp.jar uses the configuration file named
/var/myapp/myapp.conf, as shown:

Figure 5.1.1 Application Configuration

5.2 DEPLOYING SPRING BOOT APPLICATION

If you are running your application from a container, you can use an executable jar, but
it is also often an advantage to explode it and run it in a different way. Certain PaaS
implementations may also choose to unpack archives before they run. For example,
Cloud Foundry operates this way. One way to run an unpacked archive is by starting the
appropriate launcher, as follows:

$ jar -xf myapp.jar

$ java org.springframework.boot.loader.launch.JarLauncher

This is actually slightly faster on startup (depending on the size of the jar) than running
from an unexploded archive. After startup, you should not expect any differences. Once
you have unpacked the jar file, you can also get an extra boost to startup time by running
the app with its "natural" main method instead of the JarLauncher.

$ jar -xf myapp.jar

$ java -cp "BOOT-INF/classes:BOOT-INF/lib/*" com.example.MyApplication

32
It’s beneficial for the startup time to run your application using the AOT generated
initialization code. First, you need to ensure that the jar you are building includes AOT
generated code. For Maven, this means that you should build with -Pnative to activate
the native profile:
$ mvn -Pnative package

For Gradle, you need to ensure that your build includes the org.springframework.boot.aot
plugin. When the JAR has been built, run it with spring.aot.enabled system property set
to true.

$ java -Dspring.aot.enabled=true -jar myapplication.jar

Fig 5.2.1: Directory Structure of Project

33
Fig 5.2.2: Image Steganography Implementation

Fig 5.2.3: Audio Steganography Implementation

Fig 5.2.4: Image Steganography Implementation

34
CHAPTER 6
RESULTS AND DISCUSSION

The introduction of an image in another image produces noise which makes it obvious for
the steganalysts to decipher the enciphered media. The use of LSB Chaotic Mapping
algorithm makes it harder for the programmers to find the pixels which have been modified
to embed the secret image. Even if they are successful in doing so, it would be harder for
them to join the pictures into something meaningful. This algorithm does not use regular
pixel values which makes it unique.

A comprehensive and comparative study has been done with the original image and the
enciphered image for the changes. The table depicts the usage of various available
chaotic mapping algorithms and their different evaluation parameters. It also
encompasses various error calculation methods and changes in the entropies according
to the formulas and equations mentioned.

Figure 4.4.1 Welcome Page of Application when started

These days, data and information are highly valued, and transmitting and receiving data
securely is crucial. The methods utilized for secure transmission and private information
protection are cryptography and steganography. Current methods combine LSB encoding
steganography with cryptographic algorithms for encryption. They also introduce several
methods for LSB encoding using Chaotic Maps. In many eHealth applications, such as
data management, identity theft prevention, storage, and retrieval,

35
image security is crucial. This paper includes a brief explanation of few well-known picture
assaults that are used to test the performance of the suggested algorithms on images. In
order to encourage more study in this field, we have covered the cryptographic technique
and its traits, types, prerequisites, working domain, and probable problems. Moreover,
various performance measures for assessing algorithms have been shown. The paper
presents a methodology for video steganography that uses text, audio, and image files.
A carrier video is retrieved, and the frames that the audio, text, and image files can be
inserted within are used to reconstruct the video. According to the mathematical model,
the suggested architecture should perform better than the current approaches.

Figure 4.4.2 Animal.jpeg 4.4.3 Human.jpeg

Figure

Figure 4.4.4 Pic2in1.jpeg

36
Figure 4.4.5 Encryption Webpage

Figure 4.4.6 Decryption Webpage

Figure 4.4.7 Spring Application Started

37
CHAPTER 7

CONCLUSION

In conclusion, the research on multimedia steganography using the LSB chaotic


mapping method introduces a robust and secure approach for concealing messages
within images. The algorithm utilizes chaotic maps to enhance security, incorporates
Gzip compression for efficient data handling, and employs LSB embedding in color
channels to minimize visual impact. Extensive testing validates the method's
effectiveness, suggesting it as a promising technique for secure information
concealment in multimedia applications. Further research could optimize parameters
and explore alternative chaotic mapping methods, ensuring the continued evolution
of reliable and resilient steganographic techniques.

In conclusion, the LSB chaotic mapping method for multimedia steganography


stands as a promising and viable technique for secure information concealment. As
digital communication continues to evolve, the presented approach contributes to the
ongoing efforts in developing robust and reliable methods for covert data transmission
in multimedia environments.

38
REFERENCES

[1] Artz, D. 2021. Digital steganography: Hiding data within data. IEEE Internet Computing Journal,
5(3):75-80.

[2] J. Fridrich, M. Goljan and Rui Du, Detecting LSB steganography in color, and gray-scaleimages,
IEEE Multimedia, vol. 8, no. 4, pp. 22- 28, Oct.-Dec. 2021, doi: 10.1109/93.959097

[3] C. Kurak, J. McHugh, A cautionary note on image downgrading, in: Proceedings of the IEEE 8th
Annual Computer Security Applications Conference, 30 November–4December, 2022, pp. 153–
159.

[4] W. Bender, W. Butera, D. Gruhl, R. Hwang, F.J. Paiz, S. Pogreb, Applications for data hiding,
IBM Systems Journal 39 (3&4) (2022)547–568.

[5] Y. Chen, H. Wang, H. Wu, Z. Wu, T. Li, and A. Malik, “Adaptive video data hiding through cost
assignment and STCs,” IEEE Trans. Dependable Secure Comput., vol. 18, no. 3, pp. 1320– 1335,
Jun. 2021.

[6] V. Holub and J. Fridrich, “Designing steganographic distortion using directional filters,” inProc.
IEEE 4th Int. Workshop Inf. Forensics Secur., 2020, pp. 234–239.

[7] Ren T, Kotera M, Ogawa T, et al. Text-Guided Style Transfer-based Image Manipulation Using
Multimodal Generative Models. IEEE Access, 2021, PP(99):1-1.

[8] Taburet T, Bas P, Sawaya W, et al. Natural Steganography in JPEG Domain with a Linear
Development Pipeline. IEEE Transactions on Information Forensics and Security, 2020, PP(99):1-
1.

[9] Petitcolas FAP, et al. “Information hiding-a survey”. Proceedings of the IEEE, 87(7), 1062- 1078,
2020.

[10] S. Xu, et al. “No-reference/Blind Image Quality Assessment: A Survey,” IETE Tech. Rev.
(Institution Electron. Telecommun. Eng. India), vol. 34, pp. 223–245, 2017.

[11] S.Thenmozhi,M.Chandrasekaran, “Novel approach for image steganography based on integer


wavelet transform,” 2020 IEEE International Conference on Computer Intelligence and
Computing Research ,2012,pp.1-5,doi: 10.1109/ICCIC.2020.651030

[12] C. Kurak, J. McHugh, A cautionary note on image downgrading, in: Proceedings of the IEEE
8th Annual Computer Security Applications Conference, 30 November–4 December, 2022, pp.
153–159.

39
[13] W. Bender, W. Butera, D. Gruhl, R. Hwang, F.J. Paiz, S. Pogreb, Applications for datahiding,
IBM Systems Journal 39 (3&4) (2022)547–568.

[14] Y. Chen, H. Wang, H. Wu, Z. Wu, T. Li, and A. Malik, “Adaptive video data hiding through
cost assignment and STCs,” IEEE Trans. Dependable Secure Comput., vol. 18, no. 3, pp. 1320–
1335, Jun. 2021.

[15] V. Holub and J. Fridrich, “Designing steganographic distortion using directional filters,” in Proc.
IEEE 4th Int. Workshop Inf. Forensics Secur., 2020, pp. 234–239.

[16] Ren T, Kotera M, Ogawa T, et al. Text-Guided Style Transfer-based Image Manipulation Using
Multimodal Generative Models. IEEE Access, 2021, PP(99):1-1.

[17] Taburet T, Bas P, Sawaya W, et al. Natural Steganography in JPEG Domain with a Linear
Development Pipeline. IEEE Transactions on Information Forensics and Security, 2020, PP(99):1-
1.

[18] Petitcolas FAP, et al. “Information hiding-a survey”. Proceedings of the IEEE, 87(7), 1062-
1078, 2020.

[19] S. Xu, et al. “No-reference/Blind Image Quality Assessment: A Survey,” IETE Tech. Rev.
(Institution Electron. Telecommun. Eng. India), vol. 34, pp. 223–245, 2017.

[20] S.Thenmozhi,M.Chandrasekaran, “Novel approach for image steganography based


on integer wavelet transform,” 2020 IEEE International Conference on Computer
Intelligence and Computing Research ,2012,pp.1-5,doi: 10.1109/ICCIC.2020.651030

40
APPENDIX

A. SOURCE CODE

// FileDemoApplication.java

package com.example.filedemo;

import com.example.filedemo.property.FileStorageProperties;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.boot.context.properties.EnableConfigurationProperties;

@SpringBootApplication

@EnableConfigurationProperties({

FileStorageProperties.class,

})

public class FileDemoApplication {

public static void main(String[] args) {

SpringApplication.run(FileDemoApplication.class, args);

// FileStorageService.java

package com.example.filedemo.service;

import com.example.filedemo.exception.FileStorageException;

import com.example.filedemo.exception.MyFileNotFoundException;

import com.example.filedemo.property.FileStorageProperties;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.core.io.Resource;

import org.springframework.core.io.UrlResource;

41
import org.springframework.stereotype.Service;

import org.springframework.util.StringUtils;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

import java.net.MalformedURLException;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.nio.file.StandardCopyOption;

@Service

public class FileStorageService {

private Path coverFileStorageLocation;

private Path secretFileStorageLocation;

private Path encryptedFileStorageLoacation;

@Autowired

public FileStorageService(FileStorageProperties fileStorageProperties) {

this.coverFileStorageLocation = Paths.get("spring-boot-file-upload-download-
rest-api-example/src/main/resources/cover-file");

this.secretFileStorageLocation = Paths.get("spring-boot-file-upload-
download-rest-api-example/src/main/resources/secret-file");

this.encryptedFileStorageLoacation = Paths.get("spring-boot-file-upload-
download-rest-api-example/src/main/resources/encrypted-file");

try {

Files.createDirectories(this.coverFileStorageLocation);

Files.createDirectories(this.secretFileStorageLocation);

Files.createDirectories(this.encryptedFileStorageLoacation);

42
} catch (Exception ex) {

throw new FileStorageException("Could not create the directory where the


uploaded files will be stored.", ex);

public String storeCoverFile(MultipartFile file) {

// Normalize file name

String fileName = StringUtils.cleanPath(file.getOriginalFilename());

try {

// Check if the file's name contains invalid characters

if(fileName.contains("..")) {

throw new FileStorageException("Sorry! Filename contains invalid path


sequence " + fileName);

// Copy file to the target location (Replacing existing file with the same
name)

Path targetLocation = this.coverFileStorageLocation.resolve(fileName);

Files.copy(file.getInputStream(), targetLocation,
StandardCopyOption.REPLACE_EXISTING);

return fileName;

} catch (IOException ex) {

throw new FileStorageException("Could not store file " + fileName + ".


Please try again!", ex);

public String storeSecretFile(MultipartFile file) {

// Normalize file name

43
String fileName = StringUtils.cleanPath(file.getOriginalFilename());

try {

// Check if the file's name contains invalid characters

if(fileName.contains("..")) {

throw new FileStorageException("Sorry! Filename contains invalid path


sequence " + fileName);

// Copy file to the target location (Replacing existing file with the same
name)

Path targetLocation = this.secretFileStorageLocation.resolve(fileName);

Files.copy(file.getInputStream(), targetLocation,
StandardCopyOption.REPLACE_EXISTING);

return fileName;

} catch (IOException ex) {

throw new FileStorageException("Could not store file " + fileName + ".


Please try again!", ex);

public Resource loadFileAsResource(String fileName) {

try {

Path filePath =
this.coverFileStorageLocation.resolve(fileName).normalize();

Resource resource = new UrlResource(filePath.toUri());

if(resource.exists()) {

return resource;

} else {

throw new MyFileNotFoundException("File not found " + fileName);

44
}

} catch (MalformedURLException ex) {

throw new MyFileNotFoundException("File not found " + fileName, ex);

// ImageSteganography.java

package com.example.filedemo.service;

import org.opencv.core.Core;

import org.opencv.core.CvType;

import org.opencv.core.Mat;

import org.opencv.imgcodecs.Imgcodecs;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import com.example.filedemo.exception.FileStorageException;

import com.example.filedemo.property.FileStorageProperties;

import java.io.File;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.util.Random;

@Service

public class ImageSteganography {

private String input1;

private String input2;

private String output;


45
public ImageSteganography() {

String coverFile = "spring-boot-file-upload-download-rest-api-


example/src/main/resources/cover-file/";

String secretFile = "spring-boot-file-upload-download-rest-api-


example/src/main/resources/secret-file/";

//System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

nu.pattern.OpenCV.loadLocally();

File coverFolder = new File("spring-boot-file-upload-download-rest-api-


example/src/main/resources/cover-file/");

File secretFolder = new File("spring-boot-file-upload-download-rest-api-


example/src/main/resources/secret-file/");

if(coverFolder.listFiles().length != 0) {

input1 = coverFile + coverFolder.listFiles()[0].getName();

if(secretFolder.listFiles().length != 0) {

input2 = secretFile + secretFolder.listFiles()[0].getName();

output = "spring-boot-file-upload-download-rest-api-
example/src/main/resources/encrypted-file/encrypted-file.png";

public String getCoverFileLocation() {

return this.input1;

public String getSecretFileLocation() {

return this.input2;

46
public String getEncryptedFileLocation() {

return this.output;

public void encode(String input1, String input2, String output) {

Imgcodecs image1 = new Imgcodecs();

Imgcodecs image2 = new Imgcodecs();

Mat mat1 = Imgcodecs.imread(input1);

Mat mat2 = Imgcodecs.imread(input2);

for(int i=0; i<mat1.rows(); i++) {

for(int j=0; j<mat1.cols(); j++) {

double[] data2 = mat2.get(i, j);

double[] data1 = mat1.get(i, j);

for(int k=0; k<3; k++) {

int temp1 = (int)(data1[k]);

int temp2 = (int)(data2[k]);

//System.out.println(i + " " + j + " " + k + " " + temp1 + " " + temp2);

String s1 = Integer.toBinaryString(temp1);

String s2 = Integer.toBinaryString(temp2);

s1 = ("00000000" + s1).substring(s1.length());

s2 = ("00000000" + s2).substring(s2.length());

String s = s1.substring(0, 4) + s2.substring(0, 4);

data1[k] = (double)(Integer.parseInt(s, 2));

//System.out.println(i + " " + j + " " + k + " " + data1[k]);

mat1.put(i, j, data1);

}
47
}

Imgcodecs.imwrite(output, mat1);

public void decode(String path) {

Imgcodecs image = new Imgcodecs();

Imgcodecs image1 = new Imgcodecs();

Imgcodecs image2 = new Imgcodecs();

Mat mat = image.imread(path);

Mat mat1 = new Mat(mat.rows(), mat.cols(), CvType.CV_64FC3);

Mat mat2 = new Mat(mat.rows(), mat.cols(), CvType.CV_64FC3);

for(int i=0; i<mat.rows(); i++) {

for(int j=0; j<mat.cols(); j++) {

double[] data = mat.get(i, j);

double[] data1 = new double[3];

double[] data2 = new double[3];

for(int k=0; k<3; k++) {

int temp = (int)(data[k]);

String s = Integer.toBinaryString(temp);

s = ("00000000" + s).substring(s.length());

//System.out.println(i + " " + j + " " + k + " " + s);

String s1 = s.substring(0, 4) + returnRandom();

String s2 = s.substring(4) + returnRandom();

//System.out.println(i + " " + j + " " + k + " " + s1 + " " + s2);

data1[k] = (double)(Integer.parseInt(s1, 2));

data2[k] = (double)(Integer.parseInt(s2, 2));

//System.out.println(data1[k] + " " + data2[k]);


48
}

mat1.put(i, j, data1);

mat2.put(i, j, data2);

Imgcodecs.imwrite(input1 + "cover.png", mat1);

Imgcodecs.imwrite(input2 + "secret.png", mat2);

public String returnRandom() {

Random random = new Random();

String ch = String.valueOf((char)(random.nextInt(2)+48));

return String.valueOf(ch+ch+ch+ch);

// FileStorageProperties.java

package com.example.filedemo.property;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "cover")

public class FileStorageProperties {

private String uploadDir;

public String getUploadDir() {

return uploadDir;

public void setUploadDir(String uploadDir) {

this.uploadDir = uploadDir;

}
49
}

// UploadFileResponse.java

package com.example.filedemo.payload;

public class UploadFileResponse {

private String fileName;

private String fileDownloadUri;

private String fileType;

private long size;

public UploadFileResponse(String fileName, String fileDownloadUri, String


fileType, long size) {

this.fileName = fileName;

this.fileDownloadUri = fileDownloadUri;

this.fileType = fileType;

this.size = size;

public String getFileName() {

return fileName;

public void setFileName(String fileName) {

this.fileName = fileName;

public String getFileDownloadUri() {

return fileDownloadUri;

public void setFileDownloadUri(String fileDownloadUri) {

this.fileDownloadUri = fileDownloadUri;

50
}

public String getFileType() {

return fileType;

public void setFileType(String fileType) {

this.fileType = fileType;

public long getSize() {

return size;

public void setSize(long size) {

this.size = size;

// FileStorageException.java

package com.example.filedemo.exception;

public class FileStorageException extends RuntimeException {

public FileStorageException(String message) {

super(message);

public FileStorageException(String message, Throwable cause) {

super(message, cause);

// MyFileNotFoundException.java

package com.example.filedemo.exception;
51
import org.springframework.http.HttpStatus;

import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(HttpStatus.NOT_FOUND)

public class MyFileNotFoundException extends RuntimeException {

public MyFileNotFoundException(String message) {

super(message);

public MyFileNotFoundException(String message, Throwable cause) {

super(message, cause);

// FileController.java

package com.example.filedemo.controller;

import com.example.filedemo.payload.UploadFileResponse;

import com.example.filedemo.service.FileStorageService;

import com.example.filedemo.service.ImageSteganography;

import org.apache.tomcat.util.http.fileupload.FileItem;

import org.apache.tomcat.util.http.fileupload.IOUtils;

import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.core.io.Resource;

import org.springframework.http.HttpHeaders;

import org.springframework.http.MediaType;
52
import org.springframework.http.ResponseEntity;

import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

import org.springframework.web.servlet.support.ServletUriComponentsBuilder;

import java.io.*;

import java.io.FileInputStream;

import javax.servlet.http.HttpServletRequest;

import java.io.IOException;

import java.io.File;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

@RestController

public class FileController {

private static final Logger logger =


LoggerFactory.getLogger(FileController.class);

@Autowired

private FileStorageService fileStorageService;

@Autowired

private ImageSteganography imageSteganography;

@PostMapping("/uploadCoverFile")

public UploadFileResponse uploadCoverFile(@RequestParam("file")


MultipartFile file) {

String fileName = fileStorageService.storeCoverFile(file);

53
String fileDownloadUri =
ServletUriComponentsBuilder.fromCurrentContextPath()

.path("/downloadFile/")

.path(fileName)

.toUriString();

return new UploadFileResponse(fileName, fileDownloadUri,

file.getContentType(), file.getSize());

@PostMapping("/uploadSecretFile")

public UploadFileResponse uploadSecretFile(@RequestParam("file")


MultipartFile file) {

String fileName = fileStorageService.storeSecretFile(file);

String fileDownloadUri =
ServletUriComponentsBuilder.fromCurrentContextPath()

.path("/downloadFile/")

.path(fileName)

.toUriString();

return new UploadFileResponse(fileName, fileDownloadUri,

file.getContentType(), file.getSize());

@GetMapping("/getEncryptedImage")

public UploadFileResponse getEncryptedFile(HttpServletRequest request) {

String input1 = imageSteganography.getCoverFileLocation();

String input2 = imageSteganography.getSecretFileLocation();

String output = imageSteganography.getEncryptedFileLocation();

imageSteganography.encode(input1, input2, output);

54
File file = new File(output);

FileItem fileItem = null;

try {

fileItem = new DiskFileItem("mainFile",


Files.probeContentType(file.toPath()), false, file.getName(), (int) file.length(),
file.getParentFile());

InputStream input = new FileInputStream(file);

OutputStream os = fileItem.getOutputStream();

IOUtils.copy(input, os);

// Or faster..

// IOUtils.copy(new FileInputStream(file), fileItem.getOutputStream());

} catch (IOException ex) {

// do something.

MultipartFile multipartFile = new


CommonsMultipartFile((org.apache.commons.fileupload.FileItem) fileItem);

String fileDownloadUri =
ServletUriComponentsBuilder.fromCurrentContextPath()

.path("/downloadFile/")

.path(output)

.toUriString();

return new UploadFileResponse(output, fileDownloadUri,


multipartFile.getContentType(), multipartFile.getSize());

@GetMapping("/downloadFile/{fileName:.+}")

public ResponseEntity<Resource> downloadFile(@PathVariable String

55
fileName, HttpServletRequest request) {

// Load file as Resource

Resource resource = fileStorageService.loadFileAsResource(fileName);

// Try to determine file's content type

String contentType = null;

try {

contentType =
request.getServletContext().getMimeType(resource.getFile().getAbsolutePath(
));

} catch (IOException ex) {

logger.info("Could not determine file type.");

// Fallback to the default content type if type could not be determined

if(contentType == null) {

contentType = "application/octet-stream";

return ResponseEntity.ok()

.contentType(MediaType.parseMediaType(contentType))

.header(HttpHeaders.CONTENT_DISPOSITION, "attachment;
filename=\"" + resource.getFilename() + "\"")

.body(resource);

// FileDemoApplicationTests.java
package com.example.testingweb;
import org.junit.jupiter.api.Test;

56
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.web.server.LocalServerPort;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class HttpRequestTest {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate restTemplate;
@Test
void greetingShouldReturnDefaultMessage() throws Exception {
assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/",
String.class)).contains("Hello, World");
}

// application.properties

## MULTIPART (MultipartProperties)

# Enable multipart uploads

spring.servlet.multipart.enabled=true

# Threshold after which files are written to disk.

spring.servlet.multipart.file-size-threshold=2KB

# Max file size.

spring.servlet.multipart.max-file-size=200MB

# Max Request Size

spring.servlet.multipart.max-request-size=215MB

57
## File Storage Properties

# Please change this to the path where you want the uploaded files to be stored.

file.upload-dir=spring-boot-file-upload-download-rest-api-
example/src/main/resources/cover-file

secret.file.upload-dir=spring-boot-file-upload-download-rest-api-
example/src/main/resources/secret-file

// index.html

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0,


minimum-scale=1.0">

<title>Steganography</title>

<link rel="stylesheet" href="css/main.css" />

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-


bootstrap/4.1.3/css/bootstrap.min.css">

<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css
">

<link rel="stylesheet" href="css/style.css">

</head>

<body>

<noscript>

<h2>Sorry! Your browser doesn't support Javascript</h2>

</noscript>

<div class="upload-container">

<div class="upload-header">

58
<h2>Upload Files to Hide</h2>

</div>

<div class="upload-content">

<div class="cover-upload">

<h4>Upload Cover File</h3>

<form id="coverUploadForm" name="coverUploadForm">

<input id="coverFileUploadInput" type="file" name="file"


class="file-input" accept=".png, .jpg, .jpeg, .bmp" required />

<button type="submit" class="primary submit-


btn">Submit</button>

</form>

<div class="upload-response">

<div id="coverFileUploadError"></div>

<div id="coverFileUploadSuccess"></div>

</div>

</div>

<br>

<br>

<div class="secret-upload">

<h4>Upload Secret File</h3>

<form id="secretUploadForm" name="secretUploadForm">

<input id="secretFileUploadInput" type="file" name="files"


class="file-input" accept=".png, .jpg, .jpeg, .bmp" required />

<button type="submit" class="primary submit-


btn">Submit</button>

</form>

<div class="upload-response">
59
<div id="secretFileUploadError"></div>

<div id="secretFileUploadSuccess"></div>

</div>

</div>

<br><br>

<div class="generate-image">

<form id="encryptImage" name="encryptImage">

<input type="button" name="generate" value="Generate"


class="primary submit-btn" onclick="generateImage()">

</form>

<div class="upload-response">

<div id="encryptedFileDownloadError"></div>

<div id="encryptedFileDownloadSuccess"></div>

</div>

</div>

</div>

</div>

<div class="footer-basic">

<footer>

<div class="social"><a href="#"><i class="icon ion-social-


instagram"></i></a><a href="#"><i class="icon ion-social-linkedin"></i></a><a
href="#"><i class="icon ion-social-twitter"></i></a><a href="#"><i class="icon
ion-social-github"></i></a></div>

<ul class="list-inline">

<li class="list-inline-item"><a href="#">Home</a></li>

<li class="list-inline-item"><a href="#">Services</a></li>

<li class="list-inline-item"><a href="#">About</a></li>


60
<li class="list-inline-item"><a href="#">Terms</a></li>

<li class="list-inline-item"><a href="#">Privacy Policy</a></li>

</ul>

<p class="copyright">Stegos © 2024</p>

</footer>

</div>

<script src="js/main.js" ></script>

<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-
bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>

</body>

</html>

// main.js

'use strict';

var coverUploadForm = document.querySelector('#coverUploadForm');

var coverFileUploadInput = document.querySelector('#coverFileUploadInput');

var coverFileUploadError = document.querySelector('#coverFileUploadError');

var coverFileUploadSuccess =
document.querySelector('#coverFileUploadSuccess');

var secretUploadForm = document.querySelector('#secretUploadForm');

var secretFileUploadInput = document.querySelector('#secretFileUploadInput');

var secretFileUploadError = document.querySelector('#secretFileUploadError');

var secretFileUploadSuccess =
document.querySelector('#secretFileUploadSuccess');

var encryptedError = document.querySelector('#encryptedFileDownloadError');


61
var encryptedSuccess =
document.querySelector('#encryptedFileDownloadSuccess');

function uploadCoverFile(file) {

var formData = new FormData();

formData.append("file", file);

var xhr = new XMLHttpRequest();

xhr.open("POST", "/uploadCoverFile");

xhr.onload = function() {

console.log(xhr.responseText);

var response = JSON.parse(xhr.responseText);

if(xhr.status == 200) {

coverFileUploadError.style.display = "none";

coverFileUploadSuccess.innerHTML = "<p>File Uploaded


Successfully.</p><p>DownloadUrl : <a href='" + response.fileDownloadUri + "'
target='_blank'>" + response.fileDownloadUri + "</a></p>";

coverFileUploadSuccess.style.display = "block";

} else {

coverFileUploadSuccess.style.display = "none";

coverFileUploadError.innerHTML = (response && response.message) ||


"Some Error Occurred";

xhr.send(formData);

function uploadSecretFile(file) {

var formData = new FormData();


62
formData.append("file", file);

var xhr = new XMLHttpRequest();

xhr.open("POST", "/uploadSecretFile");

xhr.onload = function() {

console.log(xhr.responseText);

var response = JSON.parse(xhr.responseText);

if(xhr.status == 200) {

secretFileUploadError.style.display = "none";

secretFileUploadSuccess.innerHTML = "<p>File Uploaded


Successfully.</p><p>DownloadUrl : <a href='" + response.fileDownloadUri + "'
target='_blank'>" + response.fileDownloadUri + "</a></p>";

secretFileUploadSuccess.style.display = "block";

} else {

secretFileUploadSuccess.style.display = "none";

secretFileUploadError.innerHTML = (response && response.message) ||


"Some Error Occurred";

xhr.send(formData);//contentType(MediaType.parseMediaType(contentType))

coverUploadForm.addEventListener('submit', function(event){

var files = coverFileUploadInput.files;

if(files.length === 0) {

coverFileUploadError.innerHTML = "Please select a file";

coverFileUploadError.style.display = "block";

}
63
uploadCoverFile(files[0]);

event.preventDefault();

}, true);

secretUploadForm.addEventListener('submit', function(event){

var files = secretFileUploadInput.files;

if(files.length === 0) {

secretFileUploadError.innerHTML = "Please select a file";

secretFileUploadError.style.display = "block";

uploadSecretFile(files[0]);

event.preventDefault();

}, true);

function generateImage() {

var xhr = new XMLHttpRequest();

xhr.open("GET", "/getEncryptedImage");

xhr.onload = function() {

console.log(xhr.responseText);

var response = JSON.parse(xhr.responseText);

if(xhr.status == 200) {

encryptedError.style.display = "none";

encryptedSuccess.innerHTML = "<<p>DownloadUrl : <a href='" +


response.fileDownloadUri + "' target='_blank'>" + response.fileDownloadUri +
"</a></p>";

encryptedSuccess.style.display = "block";

} else {

encryptedSuccess.style.display = "none";

64
encryptedError.innerHTML = (response && response.message) || "Some
Error Occurred";

xhr.send();

65

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy