You are on page 1of 36

CHAPTER 1

INTRODUCTION
1.1 An Over view
With today’s ubiquitous internet service, digital images can be conveniently downloaded and
shared through social networking services (SNS) such as Facebook, Snapchat, Twitter, etc.
Therefore, there are vital needs to provide some mechanisms to manage – originally was
‘protection’ the vast number of originals images. Information hiding (i.e., data embedding) is
the process of inserting external information (e.g., ownership information and secret message)
into a medium. It is one of the possible solutions to serve the aforementioned needs. Fig. 1
illustrates the general framework during the data embedding process. Data is inserted into the
cover image with a secret key to produce an output image with embedded data, while aiming
to achieve high perceptual image quality, large embedding capacity, and strong resistance to
attacks.

In the image domain, the application of information hiding can be coarsely categorized as
watermarking and steganography. Watermarking is the practice of visibly or invisibly
embedding information into images to render the ownership. It can be retrieved for the purposes
of claiming ownership during a dispute or to detect tampering of content for integrity checking
purpose. On the other hand, steganography is the art and science of concealing the existence of
the secret communication via a cover such as image, video, audio, text, etc. The embedded
information should be unnoticeable, or in specific, perceptually undetectable by humans.

1
1.2 Objective &Scope of the Project
The aim of the project "Photo Chain" is to develop a secure and privacy-enhancing photo-
sharing platform that allows users to share their photos across different social networks while
maintaining the integrity and privacy of their photos. The project has several objectives,
including:
 To implement a face blurring algorithm using Gaussian blur,
 To protect the privacy of individuals appearing in photos shared on the platform.
 To implement a request and response-based photo access system, where users can
request access to view a photo and the photo owner can grant or deny access.
 To implement a block chain-based system for secure photo sharing, where all photo
transactions are stored on a distributed ledger, ensuring data integrity and preventing
unauthorized access.
 To implement a pre hash framework that ensures the integrity of the photo before
uploading it to the platform, ensuring that any tampering with the photo is detected.
 To enable cross-social network sharing, where photos uploaded on one social network
can be shared on another social network with the same level of security and privacy.

1.4 Problem Statement


The problem statement for the project "Photo Chain: Face Blur using Gaussian Blur, Request
and response based Photo Access System and A Block chain based Secure Photo Sharing and
Pre Hash for Photo Integrity Framework for Cross-Social Network" can be described as
follows: In today's world, people are sharing their photos online more than ever before.
However, there are concerns about the privacy and security of these photos, as well as the
integrity of the photos being shared. Photos can be easily copied, manipulated, and shared
without the consent of the owner, leading to issues such as identity theft, cyberbullying, and
more. Furthermore, there is a need to protect the privacy of individuals in photos. For example,
individuals may want to share photos of themselves without revealing their identities, such as
in cases where they are reporting a crime or sharing photos of a protest. The aim of Photo Chain
is to provide a solution to these problems by offering a secure and private photo-sharing
platform. The system will use face blurring using Gaussian blur to protect the privacy of
individuals in photos, a request and response-based photo access system to ensure that photos
are only shared with authorized individuals, and a block chain-based secure photo-sharing
system to prevent unauthorized access and manipulation of photos. Additionally, a PreHash for

2
CHAPTER 2

SYSTEM ANALYSIS
2.1 Existing System
 Most Significant Bit (MSB) of cover image
Firstly, the cover image is segmented into a number of fragments. Secondly, in order to use the
MSB of cover image to represent the secret information, the average intensity of each fragment
is calculated. Thirdly, a one-to-one mapping between the MSB of the image fragment and the
secret information is established using the mapping sequence (denote as Kr), decided by the
sender and the receiver in advance. This process produces a mapping flag (denote as Kf ),
which is sent by the sender along with the stego image.
 Coverless Image Steganography Based on Multi-object Recognition
In order to improve the robustness against geometric attacks, we propose a coverless image
steganography method based on multi-object recognition. In this scheme, we firstly use Faster
RCNN to detect objects in the image data set, establish a mapping dictionary between object
labels and binary sequence. Then we propose a novel mapping rule based on the filtered robust
object labels for sequence generation. Therefore, an image can generate robust binary sequence
through multi-objects recognition. In the transmission process, the transmitted image has not
been modified, so our method can fundamentally resist stego analysis tools and avoid the
attacker’s suspicions.
 Coverless Image Steganography using HAAR Integer Wavelet Transform
This method focuses on increasing the amount of data transmitted in an image, when using
coverless image steganography through the use of the HAAR Integer Wavelet Transform. In
our method, we take a single image of resolution 256×256 and split it into 1024 sub matrices.
After that, we use integer wavelet transform to generate the coefficients in each sub-matrix.
These sub-matrices are reshaped into arrays. Then the coefficients of each sub-matrix are
changed into binary bits, by checking whether the succeeding value in the array is larger or
smaller than the current value which leads to an array of length 1064*63. finally, we fragment
the secret message into 8 bits and match it with the block and starting location in the array. A
location map is generated which can be used by the receiver to obtain the secret message.

3
 Coverless Image Steganography Based on DCT and LDA Topic Classification
In order to improve the robustness and capability of resisting image steganalysis, a novel
coverless image steganography algorithm based on discrete cosine transform and latent
dirichlet allocation (LDA) topic classification is proposed. First, latent dirichlet allocation topic
model is utilized for classifying the image database. Second, the images belonging to one topic
are selected, and 8 × 8 block discrete cosine transform is performed to these images. Then
robust feature sequence is generated through the relation between direct current coefficients in
the adjacent blocks. Finally, an inverted index which contains the feature sequence, dc, location
coordinates, and image path is created. For the purpose of achieving image steganography, the
secret information is converted into a binary sequence and partitioned into segments, and the
image whose feature sequence equals to the secret information segments is chosen as the cover
image according to the index. After that, all cover images are sent to the receiver. In the whole
process, no modification is done to the original images.

2.2 Disadvantages
 low capacity and poor quality
 accuracy decreases substantially for state values far from the steady state
 Higher complexity
 it is difficult to resist detection based on high-dimensional statistical characterization
 Three weakness- Robustness, Tamper and Resistance.
 Extremely sensitive to any kind of filtering.
 Scaling, Rotation, Cropping, adding extra noise lead to destroy the secret message.

2.3 Proposed System


Since the concept of coverless information hiding was proposed, it has been greatly developed
due to its effectiveness of resisting the steganographic tools. Most existing coverless image
steganography (CIS) methods achieve excellent robustness under non-geometric attacks.
However, they do not perform well under some geometric attacks. Towards this goal, a CIS
algorithm based on DenseNet feature mapping is proposed. Deep learning is introduced to

4
extract high-dimensional CNN features which are mapped into hash sequences. For the sender,
a binary tree hash index is built to accelerate index speed of searching hidden information and
DenseNet hash sequence, and then, all matched images are sent. For the receiver, the secret
information can be recovered successfully by calculating the DenseNet hash sequence of the
cover image.
 We propose a novel hash mapping rules based on CNN feature, and it improves the
robustness against geometric attacks. Compared with other manual features, it is more
able to capture the global features of the image when losing some content. Besides, we
also do a series of experiments on existing network model and chose the optimal
network model (DenseNet).
 An efficient binary tree hash index based on bitwise indexing is designed to speed up
the search of cover images for secret information.
The process of secret information hiding and extraction is shown in Fig. 2. The framework of
the proposed approach is composed of three parts, which are implemented in four steps:
generation of hash sequence, construction of binary tree hash index, coverless image
steganography, and extraction of secret information. In our approach, the pretrained DenseNet
model is firstly used to extract the features of the image database. For the feature of each image,
it is divided into D blocks and the feature coefficient Me of each

5
block is calculated. Then, feature coefficients Me are scanned by “arithmetic scan”(steplength
set to sl) to generate the hash sequence. Next, the secret information is divided into segments
equal to the hash sequence N, and the search cover images are searched through matching with
the hash sequence. Finally, all cover images sent to the receiver in order, such that the receiver
could recover secret information by calculating received images under the same hash
algorithm. Considering that the length of the sequence may not be a multiple of N, 0 is filled
in the last segment of the partition, and the number of 0 is recorded in the last image.

2.4 Advantages
 the proposed method has good performance against such as AGWN, salt & pepper
noise, low-pass filtering and JPEG compression attacks.

 the proposed system has a good security, and it is very difficult for malicious attackers
to crack the system.

 the cover image especially will not be modified in the process of hiding and extracting
secret information, thus ensuring the security of secret information.

 Low computational expense, even with high dimensional state space

 the proposed scheme has better robust compared with the state-of-the-art methods under
geometric attacks.

2.5 Methodology/Algorithm
1. Architecture: The PhotoChain system comprises of three primary components - the
Client, Server and Blockchain network. The Client can be a mobile app or a web app
that allows users to upload and share photos with friends across social networks. The
Server acts as a mediator between the Client and the Blockchain network. The
Blockchain network is responsible for securely storing all photo metadata and user
credentials.
2. Face Blur using Gaussian Blur: When a user uploads a photo to PhotoChain, the system
automatically detects all faces in the photo and applies a Gaussian Blur to each face.
The degree of blur can be adjusted by the user depending on the sensitivity of the photo.

6
3. Request and Presponse based Photo Access System: To access a photo on PhotoChain,
a user must send a request to the photo owner. The photo owner then has the option to
accept or decline the request. Once the request is accepted, the photo is visible to the
requester.
4. Blockchain based Secure Photo Sharing: All photo metadata is stored on a Blockchain
network that ensures secure sharing of photos across social networks. Only authorized
users with valid credentials can access the photo metadata and associated photos.
5. PreHash for Photo Integrity: To ensure the integrity of photos, a prehash of each photo
is computed and stored on the Blockchain network. This prehash can be used to verify
if the photo has been tampered with.

7
CHAPTER 3
System Specification
3.1 Hardware specification
 Processors: Intel® Core™ i5 processor 4300M at 2.60 GHz or 2.59 GHz (1
socket, 2 cores, 2 threads per core), 8 GB of DRAM
 Disk space: 320 GB
 Operating systems: Windows® 10, mac OS*, and Linux*
3.2 Software specification
 Server Side : Python 3.7.4(64-bit) or (32-bit)
 Client Side : HTML, CSS, Bootstrap
 IDE : Flask 1.1.1
 Back end : MySQL 5.
 Server : WAMP Server 2i
 OS : Windows 10 64 –bit or Ubuntu 18.04 LTS “Bionic Beaver”

8
CHAPTER 4
SYSTEM DESIGN

Social Networking Sites

Access Control Policy

Request/Response Privacy Policy

Chat/Post/Share/Com Photo Sharing Security


ments
Create Friends n Family
Groups
Key Generation

Login Photo Enc/Dec

Registration Photo Blurring

New / Existing User


Block user

Historical Data Analyzer

Social Networking Users

9
3.1 Data Base Structure
Database: photo_chain
Table structure for table pc_user_details

Field Type Key


id int(11)
name varchar(20)
gender varchar(10)
dob Varchar(15)
city Varchar(20)
profession Varchar(30)
email varchar(40)
username varchar(20) Primary Key
password varchar(20)
profile_image varchar(50)
Create_date Varchar(20)

Table structure for table pc_friend_request

Field Type Key


id int(11)
Username varchar(20) Foreign Key
Friend_id varchar(20)
status int(11)

Table structure for table pc_post

Field Type Key


id int(11)
Username varchar(20) Foreign Key
Post_message text

10
Photo varchar(100)
Post_date varchar(20)
Post_time Timestamp
status int(11)

Table structure for table pc_post_request

Field Type Key


id int(11)
Username varchar(20) Foreign Key
Post_id Text
Access_request Int(11)

3.2 Data Flow Diagram

Level - 0

Account Creation Maintain this website


Social
SN User Account Networking Site Admin
Approval web App
Login
Update User Meta Info

Enable SC, Gen Hash

SN DB
Key, Gen Block

Store user Data

PhotoChain

11
Level – 1

SU User 2
(friends)

Approve/Reject Request to View

Login
Social SU User 2
SN User 1 Networking View Photo
Upload Photo Web App (friends)

Response to req.
Store user Data

Import Photo
SN DB

Phot Sharing Privacy

Store hash Photo


Download Protection,
Full Blur, Face Blur.
Transfer photo Meta
info with UID

Create
Block,Hash
Photo,

PhotoChain

12
Level – 2

SU User 2
(friends)

Approve/Reject Request to View

Login
Social SU User 2
SN User 1 Networking View Photo
Upload Photo Web App (friends)

Response to req.

Post on User
Store user Data
Hash Key
PhotoChain

Tamper Proof
Block with
Transaction
Photo

account
Import Photo

SN DB

Phot Sharing
Full Blur, Face Blur

Store hash Photo


Photo Integrity (Gaussian Blur)
Check,
(PreHash)
Transfer photo Meta
info with UID

Create
Block,Hash
Photo,

PhotoChain

13
3.3 System Flow Diagram

SN User

Request to View Photo


Blurring Friend Face

Photo n Text Encoding

Sharing Encoded Photo Rejected Accepted

Encrypted View Auto Decode

View Photo n
Msg

Friends Group

Others Group

14
CHAPTER 5
SYSTEM IMPLEMENTATION
5.1 Modules Description
1. SN Web App
Build a social networking service is an online platform in which people use to build social
networks or social relationships with other people who share similar personal or career
interests, activities, backgrounds or real-life connections. Social networking services vary in
format and the number of features.
2. Ender user Cpanel
2.1. Register
Users in this application, who want to access and share their images into this site, they should
register their information in this site. After they registered their data in this site, they can log
into the application for providing and accessing images which are shared by their friends or
some other persons in social networks. Users can not only look at the images from this site, but
also, they can upload their images either by private or public. In which, users can give friend
requests, accept friend requests, and key request to reveal private images in the site.
2.2. Login
The user will demonstrate social network features wherein he will perform following
operations: [1] Edit Profile [2] View and Add Friends [3] Search Users [4] View User Profile
2.3. Add Friends /Family Groups
Friend Request A log in/out button could be used for log in/out with the social website. After
logging in, a greeting message and the profile picture will be shown. This prototype works in
three modes: a setup mode, a sleeping mode and a working mode.
Picking Close Friends, A user needs to manually specify the set of "close friends" from their
friend list on social website and form the neighbourhood by clicking the button "Pick friends".
2.4. Share/Post/Comment/Chat
Sharing Photo User can share a photo only to friends on list. According to the proposed scheme,
this friend list should be intersection of owner's privacy policy and co-owners' exposure
policies.
Policy mining: Users can establish the uploaded image whether the image is private or public;
then eligible users (friend only view the public images) can access these images otherwise
images will be hidden. If users want to view private content, then the content owner should
provide the key for that image. Policy mining is carried out within the same category because

15
images in the same category are more likely under a similar level of privacy protection. E)
Policy prediction: In this phase they generate several candidate policies while the goal of this
system is to return the most promising one to the user. Thus, it presents an approach to choose
the best candidate policy that follows the user’s privacy tendency. It provides a predicted policy
of a newly uploaded image to the user for their reference
2.5. Request/Response
To respond to a friend request, you have two choices. One is to click one of the two buttons to
the right of your potential friend's name. One button reads Confirm and one reads Not Now.
Click one of those buttons and (respectively) you add a friend or ignore the request quietly.
3. Photo Privacy
3.1. Key Generation
In this process, privacy information of the photo is protected by using the selected protection
tool and a secret key (or a set of keys) set by the sender. Apart from providing a proper security
level and an efficient implementation, one relevant challenge is to properly manage all the
encryption keys used in the system. We propose a centralised approach where all keys are
stored in the trusted Key Server.
It is essential that the server is able to uniquely identify images in order to be able to generate
unique keys for each picture and region in it. As we have mentioned, the Key Server randomly
generates a unique identifier for each protected picture that is sent back to the LockPic
application at encryption time. This unique ID is included in the metadata of the encrypted
picture. Another approach could be to use the hash of the picture as ID. The problem of using
the hash as the ID is that the hash has to be performed in the mobile application, which might
be an expensive operation depending on the size of the picture, and could present security
problems in the case that hash collisions are found. More importantly, the key server would be
able to analyse some usage patterns as it would be able to recognize if two different users
encrypt the same picture.
3.2. Photo and Message Encode/Decode
Image and Message Encoding
Our encoder network consists of downsampling layers, residual layers, and upsampling layers.
The structure of encoder network is shown in Fig. 2. In the resnet, it includes many skip
connections to fuse the shallow features and deep features in the different convolution stages.
The shallow feature includes a lot of low-level efficient information about the outline and color
of image, which is very beneficial for the generation of steganographic images. The works of
constructed the encoder network similar to the structure of U-Net, and its results have proved

16
that the skip connection is effective to reduce the distortion of steganographic images and
improve the visual quality of steganographic images.

Image and Message Decoding


The decoder network composed of a 6-layer full convolutional network extracts the secret color
images (S’) from steganographic images (C’). The decoder network and the encoder network
in the previous section constitute the generator of the proposed model HIGAN. The architecture
of the decoder network has been proven in previous work to effectively reconstruct single-
channel grayscale secret images and three-channel color secret images. All 3×3 convolutional
layers with stride 1 and padding 1 are followed by batch normalization (BN) operation and
ReLU activation function. But, sigmoid activation function was used after the last
convolutional layers. Finally, the decoder network reveals the secret image S’.

17
3.3. Photo Blurring
Gaussian blur (also known as Gaussian smoothing) is the result of blurring an image by a
Gaussian function (named after mathematician and scientist Carl Friedrich Gauss).
It is a widely used effect in graphics software, typically to reduce image noise and reduce detail.
The visual effect of this blurring technique is a smooth blur resembling that of viewing the
image through a translucent screen, distinctly different from the bokeh effect produced by an
out-of-focus lens or the shadow of an object under usual illumination.
Gaussian smoothing is also used as a pre-processing stage in computer vision algorithms in
order to enhance image structures at different scales—see scale space representation and scale
space implementation.
4.Privacy Violation
Check Policy Status The privacy policy status is set for individual users. The policy should
satisfy both the privacy policy and the exposure policy of the individuals.
Post or Block If the policy is satisfied then the notification is sent to the co-owner. The photo
is posted once the owner gives permission to upload it else it is not uploaded.

18
CHAPTER 6
SYSTEM TESTING

6.1 TESTING PROCESS


The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality
of components, sub-assemblies, assemblies and/or a finished product it is the process of
exercising software with the intent of ensuring that the Software system meets its requirements
and user expectations and does not fail in an unacceptable manner. There are various types of
test. Each test type addresses a specific testing requirement.
TYPES OF TESTING
Unit Testing
Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision branches
and internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing that relies on knowledge of its construction and is invasive. Unit tests perform
basic tests at component level and test a specific business process, application and/or system
configuration. Unit tests ensure that each unique path of a business process performs accurately
to the documented specifications and contains clearly defined inputs and expected results. Unit
testing is usually conducted as part of a combined code and unit test phase of the software
lifecycle, although it is not uncommon for coding and unit testing to be conducted as two
distinct phases. Test objectives
 All field entries must work properly.
 Pages must be activated from the identified link.
 The entry screen, messages and responses must not be delayed.
Features to be tested
 Verify that the entries are of the correct format.
 No duplicate entries should be allowed.
 All links should take the user to the correct page.

19
7.2.2 Integration Testing
Integration tests are designed to test integrated software components to determine if they
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown by successfully unit testing, the combination of components
is correct and consistent. Integration testing is specifically aimed at exposing the problems
that arise from the combination of components. Software integration testing is the incremental
integration testing of two or more integrated software components on a single platform to
produce failures caused by interface defects. The task of the integration test is to check that
components or software applications, e.g. components in a software system or – one step up
software applications at the company level interact without error. Test Results: All the test
cases mentioned above passed successfully. No defects encountered.
Functional Testing
Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user manuals.
Functional testing is centered on the following items:
Valid Input : identified classes of valid input must be accepted.
Invalid Input : identified classes of invalid input must be rejected.
Functions : identified functions must be exercised.
Output : identified classes of application outputs must be exercised.
Systems/Procedures: interfacing systems or procedures must be invoked. Organization and
preparation of functional tests is focused on requirements, key functions, or special test cases.
In addition, systematic coverage pertaining to identify Business process flows; data fields,
predefined processes, and successive processes must be considered for testing. Before
functional testing is complete, additional tests are identified and the effective value of current
tests is determined.
System Test
System testing ensures that the entire integrated software system meets requirements. It tests
a configuration to ensure known and predictable results. An example of system testing is the
configuration-oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.

20
White Box Testing
White Box Testing is a testing in which in which the software tester has knowledge of the inner
workings, structure and language of the software, or at least its purpose. It is purpose. It is used
to test areas that cannot be reached from a black box level.

Black Box Testing


Black Box Testing is testing the software without any knowledge of the inner workings,
structure or language of the module being tested. Black box tests, as most other kinds of tests,
must be written from a definitive source document, such as specification or requirements
document, such as specification or requirements document. It is a testing in which the software
under test is treated, as a black box .you cannot “see” into it. The test provides inputs and
responds to outputs without considering how the software works.
Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional requirements.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.

21
CHAPTER 7
CONCLUSION
This project proposed a new idea for CIH. Driven by secret information and constrained by
attribute labels, it directly generates anime character with high quality to transmit secret
information. Compared with the current cover selection methods, proposed method has a great
improvement in capacity. However, there is a gap in robustness compared with the current
robust coverless information hiding methods. The next step is to improve the robustness of the
method by optimizing the generation model. This paper provides a more practical solution for
the development of coverless information hiding, that is, to express secret information in the
process of generating target images according to attributes, which has certain guiding
significance for the development of coverless information hiding.

CHAPTER 8
SCOPE OF FUTURE ENHANCEMENT

The next plan is to develop a steganography technique that is robust to different types of attacks
and also work can be enhanced for other data files like audio, video, and text. By these methods
we can achieve best completeness, correctness, quality and accuracy.

22
CHAPTER 9
REFERENCE
] Prema, G.; Natarajan, S., "Steganography using Genetic Algorithm along with Visual
Cryptography for wireless network application," Information Communication and Embedded
Systems (ICICES), 2013 International Conference on , vol., no., pp.727,730, 21-22 Feb. 2013.
[2] Nickfarjam, A.M.; Azimifar, Z., "Image steganography based on pixel ranking and Particle
Swarm Optimization," Artificial Intelligence and Signal Processing (AISP), 2012 16th CSI
International Symposium on , vol., no., pp.360,363, 2-3 May 2012.
[3] Sanchez, A.; Conci, A.; Zeljkovic, E.; Behlilovic, N.; Karahodzic, V., "A new approach to
relatively short message steganography," Telecommunications (BIHTEL), 2012 IX
International Symposium on , vol., no., pp.1,4, 25-27 Oct. 2012.
[4] Qiangfu Zhao; Akatsuka, M.; Cheng-Hsiung Hsieh, "Generating facial images for
steganography based on IGA and image morphing," Systems, Man, and Cybernetics (SMC),
2012 IEEE International Conference on , vol., no., pp.364,369, 14-17 Oct. 2012.
[5] Khosravi, M.; Soleymanpour-Moghaddam, S.; Mahyabadi, M., "Improved pair-wise LSB
matching steganography with a new evaluating system," Telecommunications (IST), 2012
Sixth International Symposium on , vol., no., pp.982,986, 6-8 Nov. 2012.
[6] Brazil, A.L.; Sanchez, A.; Conci, A.; Behlilovic, N., "Hybridizing genetic algorithms and
path relinking for steganography," ELMAR, 2011 Proceedings , vol., no., pp.285,288, 14-16
Sept. 2011.
[7] Bhowal, K.; Sarkar, D.; Biswas, S.; Sarkar, P.P., "Secured image transmission with GA
based Audio Steganography," India Conference (INDICON), 2011 Annual IEEE , vol., no.,
pp.1,4, 16-18 Dec. 2011.
[8] Mandal, J.K.; Khamrui, A., "A Genetic Algorithm based steganography in frequency
domain (GASFD)," Communication and Industrial Application (ICCIA), 2011 International
Conference on , vol., no., pp.1,4, 26-28 Dec. 2011.
[9] W. Tang, S. Tan, B. Li, and J. Huang, ‘‘Automatic steganographic distortion learning using
a generative adversarial network,’’ IEEE Signal Process. Lett., vol. 24, no. 10, pp. 1547–1551,
Oct. 2017.
[10] H. Naito and Q. Zhao, ‘‘A new steganography method based on generative adversarial
networks,’’ in Proc. IEEE 10th Int. Conf. Awareness Sci. Technol. (iCAST), Oct. 2019, pp. 1–
6.

23
CHAPTER 10
APPENDICES
10.1 SOURCE CODE

Sample Source Code


Packages
from flask import Flask, flash, render_template, Response, redirect, request, session, abort,
url_for
from camera import VideoCamera
import mysql.connector
import hashlib
import datetime
import cv2
import imagehash
import shutil
import PIL.Image
from PIL import Image

Database Connection
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
charset="utf8",
database="photo_chain"
)

User Account Creation


def register():
msg=""

24
mycursor = mydb.cursor()
mycursor.execute("SELECT max(id)+1 FROM ds_register")
maxid = mycursor.fetchone()[0]
if maxid is None:
maxid=1
if request.method=='POST':
name=request.form['name']
gender=request.form['gender']
dob=request.form['dob']
aadhar=request.form['aadhar']
email=request.form['email']
uname=request.form['uname']
pass1=request.form['pass']

mycursor.execute('SELECT count(*) FROM ds_register WHERE uname = %s ||


aadhar=%s', (uname,aadhar))
cnt = mycursor.fetchone()[0]
if cnt==0:
now = datetime.now()
rdate=now.strftime("%d-%m-%Y")
adr=str(aadhar)
rn=randint(50,90)
v1=name[0:2]
v2=str(rn)
v3=adr[0:3]
bkey=v1+str(maxid)+v2+v3
sql = "INSERT INTO
ds_register(id,name,gender,dob,email,aadhar,uname,pass,create_date,block_key) VALUES
(%s,%s, %s, %s, %s, %s,%s,%s,%s,%s)"
val = (maxid,name,gender,dob,email,aadhar,uname,pass1,rdate,bkey)
mycursor.execute(sql, val)

25
mydb.commit()
print(mycursor.rowcount, "Registered Success")
mess="Dear "+name+", Username: "+uname+", Password: "+pass1+", Block Key:
"+bkey
msg="success"
vid=str(maxid)
nam="1"
mycursor.execute('SELECT * FROM ds_register WHERE uname=%s', (uname,))
dd = mycursor.fetchone()
dtime=str(dd[11])
bdata="ID:"+str(maxid)+", Username:"+uname+", Status:Registered,
Aadhar:"+aadhar+", Date: "+dtime
else:
msg='fail'

Login
def index():
msg=""
if request.method=='POST':
uname=request.form['uname']
pwd=request.form['pass']
cursor = mydb.cursor()
cursor.execute('SELECT * FROM ds_register WHERE uname = %s AND pass = %s',
(uname, pwd))
account = cursor.fetchone()
if account:
session['username'] = uname
return redirect(url_for('userhome'))
else:
msg = 'Incorrect username/password!'

26
Friend Request
#####send req######
if act=="send":
cname=request.args.get("cname")
mycursor.execute("SELECT max(id)+1 FROM ds_contact")
maxid = mycursor.fetchone()[0]
if maxid is None:
maxid=1
sql = "INSERT INTO ds_contact(id,uname,cname,status) VALUES(%s,%s,%s,%s)"
val = (maxid,uname,cname,'1')
mycursor.execute(sql,val)
mydb.commit()
maxid2=maxid+1
sql = "INSERT INTO ds_contact(id,uname,cname,status) VALUES(%s,%s,%s,%s)"
val = (maxid2,cname,uname,'0')
mycursor.execute(sql,val)
mydb.commit()
msg="sent"

Confirm Friend
if act=="confirm":
cname=request.args.get("cname")
mycursor.execute("update ds_contact set status=1 where uname=%s && cname=%s
&& status=0",(uname,cname))
mydb.commit()
mycursor.execute("update ds_contact set status=1 where uname=%s && cname=%s
&& status=0",(cname,uname))
mydb.commit()
mycursor.execute('SELECT * FROM ds_contact where uname=%s && cname=%s &&
status=1',(cname,uname))
cbq = mycursor.fetchone()

27
dtime=str(cbq[4])
bdata="ID:"+str(vid)+", Username:"+uname+", Status:Confirm to "+cname+",
Date:"+dtime
msg="confirm"

Upload Post
if request.method == 'POST':
detail= request.form['detail']
if 'file' not in request.files:
flash('No file Part')
return redirect(request.url)
file= request.files['file']
file_name=""
mycursor.execute("SELECT max(id)+1 FROM ds_post")
maxid = mycursor.fetchone()[0]
if maxid is None:
maxid=1
pid=str(maxid)
if file.filename == '':
flash('No Select file')
return redirect(request.url)
if file:
fname1 = file.filename
fname = secure_filename(fname1)
file_name="P"+str(maxid)+fname
file.save(os.path.join("static/comments/", file_name))

Face Blur
def blurImage(img,pid):
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# plotting the original image

28
face_detect = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
face_data = face_detect.detectMultiScale(image, 1.3, 5)
# Draw rectangle around the faces which is our region of interest (ROI)
apos=[]
j=1
for (x, y, w, h) in face_data:
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
roi = image[y:y+h, x:x+w]
pp=str(x)+"-"+str(y)
apos.append(pp)
cropped = image[y:y+h, x:x+w]
gg="g"+pid+"_"+str(j)+".jpg"
cv2.imwrite("static/group/"+gg, cropped)
# applying a gaussian blur over this new rectangle area
roi = cv2.GaussianBlur(roi, (23, 23), 30)
# impose this blurred image on original image to get final image
image[y:y+roi.shape[0], x:x+roi.shape[1]] = roi
j+=1
fn="F"+img
cv2.imwrite("static/comments/"+fn, image)
Full Blur
def fullBlur(img,pid):
img1 = cv2.imread("static/comments/"+img)
fn="B"+img
avging = cv2.blur(img1,(20,20))
cv2.imwrite("static/comments/"+fn, avging)

Unblur Photo
if request.method == 'POST':
gx=request.form.getlist("gx[]")

29
print(gx)
for g1 in gx:
g2=g1.split(".")
g3=g2[0].split("_")
garr.append(g3[1])

image = cv2.imread("static/comments/"+fn)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
face_detect = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
face_data = face_detect.detectMultiScale(image, 1.3, 5)
k=1
for (x, y, w, h) in face_data:
kk=str(k)
if kk in garr:
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
roi = image[y:y+h, x:x+w]
roi = cv2.GaussianBlur(roi, (23, 23), 30)
image[y:y+roi.shape[0], x:x+roi.shape[1]] = roi
else:
roi = image[y:y+h, x:x+w]
image [y: y+ r o i. shape[0], x:x+roi.shape[1]] = roi
k+=1
fnn="G"+fn
cv2.imwrite("static/comments/"+fnn, image)
mycursor.execute("update ds_post set pimage=%s where id=%s",(fn,pid))
mydb.commit()

30
10.2 Sample Screen

31
32
33
34
35
36

You might also like