Professional Documents
Culture Documents
INTRODUCTION
Public clouds are owned and operated by third parties; they deliver superior
economies of scale to customers, as the infrastructure costs are spread among a mix
of users, giving each individual client an attractive low-cost, “Pay-as-you-go”
model. All customers share the same infrastructure pool with limited configuration,
security protections, and availability variances. These are managed and supported
by the cloud provider. One of the advantages of a Public cloud is that they may be
larger than an enterprises cloud, thus providing the ability to scale seamlessly, on
demand.
Private clouds are built exclusively for a single enterprise. They aim to address
concerns on data security and offer greater control, which is typically lacking in a
public cloud. There are two variations to a private cloud:
On-premise Private Cloud: On-premise private clouds, also known as
internal clouds are hosted within one own data centre. This model provides a
more standardized process and protection, but is limited in aspects of size and
scalability. IT departments would also need to incur the capital and
operational costs for the physical resources. This is best suited for
applications which require complete control and configurability of the
infrastructure and security.
Externally hosted Private Cloud: This type of private cloud is hosted
externally with a cloud provider, where the provider facilitates an exclusive
cloud environment with full guarantee of privacy. This is best suited for
enterprises that don't prefer a public cloud due to sharing of physical
resources.
Hybrid Clouds combine both public and private cloud models. With a Hybrid
Cloud, service providers can utilize 3rd party Cloud Providers in a full or partial
manner thus increasing the flexibility of computing. The Hybrid cloud environment
is capable of providing on-demand, externally provisioned scale. The ability to
augment a private cloud with the resources of a public cloud can be used to manage
any unexpected surges in workload.
The scope of the project is key aggregate searchable encryption (KASE) and
instantiating the concept through a concrete KASE scheme, in which a data owner
only needs to distribute a single key to a user for sharing a large number of
documents, and the user only needs to submit a single trapdoor to the cloud for
querying the shared documents.
Consider a scenario where two employees of a company would like to share
some confidential business data using a public cloud storage service. For instance,
Alice wants to upload a large collection of financial documents to the cloud storage,
which are meant for the directors of different departments to review. Suppose those
documents contain highly sensitive information that should only be accessed by
authorised users, and Bob is one of the directors and is thus authorized to view
documents related to his department. Due to concerns about potential data leakage
in the cloud, Alice encrypts these documents with different keys, and generates
keyword ciphertexts based on department names, before uploading to the cloud
storage. Alice then uploads and shares those documents with the directors using the
sharing functionality of the cloud storage. In order for Bob to view the documents
related to his department, Alice must delegate to Bob the rights both for keyword
search over those documents, and for decryption of documents related to Bob’s
department.
In KASE, Alice only needs to distribute a single aggregate key, instead for
sharing m documents with Bob, and Bob only needs to submit a single aggregate
trapdoor, to the cloud server. The cloud server can use this aggregate trapdoor and
some public information to perform keyword search and return the result to Bob.
Therefore, in KASE, the delegation of keyword search right can be achieved by
sharing the single aggregate key. We note that the delegation of decryption rights
can be achieved using the key-aggregate encryption approach recently proposed in,
but it remains an open problem to delegate the keyword search rights together with
the decryption rights, which is the subject topic of this paper.
The three issues of cloud computing security are: confidentiality, integrity and
availability.
A. Availability
B. Integrity
Integrity is the assurance that the data sent is same as the message received
and it is not altered in between. Integrity is infringed if the transmitted message is
not same as received one. It is ensured by: Firewalls and intrusion detection.
C. Confidentiality
Security and privacy are very important issues in cloud computing. The aim
is to build practical data sharing system based on public cloud storage to avoid
inadvertent data leaks in the cloud and privacy for preserving data.
Our main contributions are as follows.
1) First define a general framework of key aggregate searchable encryption (KASE)
composed of seven polynomial algorithms for security parameter setup, key
generation, encryption, key extraction, trapdoor generation, trapdoor adjustment,
and trapdoor testing. We then describe both functional and security requirements for
designing a valid KASE scheme.
2) Then instantiate the KASE framework by designing a concrete KASE scheme.
After providing detailed constructions for the seven algorithms, we analyze the
efficiency of the scheme, and establish its security through detailed analysis.
3) Discuss various practical issues in building actual group data sharing system
based on the proposed KASE scheme, and evaluate its performance. The evaluation
confirms our system can meet the performance requirements of practical
applications.
The proposed KASE scheme applies to any cloud storage that supports the
searchable group data sharing functionality, which means any user may selectively
share a group of selected files with a group of selected users, while allowing the
latter to perform keyword search over the former. To support searchable group data
sharing the main requirements for efficient key management are twofold. First, a
data owner only needs to distribute a single aggregate key (instead of a group of
keys) to a user for sharing any number of files. Second, the user only needs to submit
a single aggregate trapdoor (instead of a group of trapdoors) to the cloud for
performing keyword search over any number of shared files. To the best of our
knowledge, the KASE scheme proposed in this paper is the first known scheme that
can satisfy both requirements (the key-aggregate cryptosystem, which has inspired
our work, can satisfy the first requirement but not the second).
The goal of KASE is to delegate the keyword search right to any user by distributing
the aggregate key to him/her in a group data sharing system, whereas the goal of
MKSE is to ensure the cloud server can perform keyword search with one trapdoor
over different documents owing to a user.
2. SYSTEM STUDY
The document provide the feasibility of the project that is being designed and
lists various areas that were considered very carefully during the feasibility study of
this project such as Technical, Economic and Operational feasibilities. The
following are its features:
Technical Feasibility
The system must be evaluated from the technical point of view first. The
assessment of this feasibility must be based on an outline design of the system
requirement in the terms of input, output, programs and procedures. Having
identified an outline system, the investigation must go on to suggest the type of
equipment, required method developing the system, of running the system once it
has been designed.
The project should be developed such that the necessary functions and
performance are achieved within the constraints. The project is developed within
latest technology. Through the technology may become obsolete after some period
of time, due to the fact that never version of same software supports older versions,
the system may still be used. So there are minimal constraints involved with this
project. The system has been developed using Asp.net the project is technically
feasible for development.
Economic Feasibility
The developing system must be justified by cost and benefit. Criteria to ensure
that effort is concentrated on project, which will give best, return at the earliest. One
of the factors, which affect the development of a new system, is the cost it would
require.
The following are some of the important financial questions asked during
preliminary investigation:
Since the system is developed as part of project work, there is no manual cost
to spend for the proposed system. Also all the resources are already available, it give
an indication of the system is economically possible for development.
Front-end and back-end selection
Front-end selection
1. It must have a graphical user interface that assists employees that are not from IT
background.
3. Flexibility.
4. Robustness.
7. Platform independent.
10. Front end must support some popular back end like Ms SqlServer.
According to the above stated features we selected C#.net as the front-end for
developing our project.
Back-end Selection
5. Stored procedures.
6. Popularity.
8. Easy to install.
Operational Feasibility
RAM : 2 GB
Friend List
This module create a relationship between inviting and invited user. Allows
you to add members to your friends list. When an invited friend joins the site then
that person is automatically added to the member that invited them.
Share Comments and Photos
The module excels at two roles. Its first role is that of a web gallery on
presentation web pages maintained by the web master or site owner. The second role
refers to community oriented sites, where users can upload their images, comment
are share to social networks. The module also shows the shared comments and
photos from already invited friends.
B) Key Aggregate Searchable Cryptosystem
Cloud Storage
Cloud storage is a storage of data online in cloud which is accessible from
multiple and connected resources. As increase in outsourcing of data the cloud
computing serves does the management of data. The main concern is how to share
the data securely the answer is cryptography. Cryptography helps the data owner to
share the data to in safe way. A user can upload a file and store it securely in the
cloud. Privacy preserving mechanism, all the photos were encrypted and uploading
to cloud server.
Key Aggregate Searchable Encryption
A key-aggregate encryption scheme consists of seven polynomial-time
algorithms: Setup, Keygen, Encrypt, Extract, Trapdoor, Adjust and Test. The main
idea of data sharing in cloud storage using KASE wants to share her data on the
server. The sizes of cipher-text, public-key, and master-secret key and aggregate key
in our KAC schemes are all of constant size. The key owner holds a master-secret
called master-secret key, which can be used to extract secret keys for different
classes.
Setup Phase
The data owner establishes the public system parameter i.e, randomly pick a
bilinear group G of prime order p and q. It executed by the data owner to setup an
account on an untrusted server. Input a security level parameter and output the
system parameter as param. It is needed each time and it can be fetched on demand
from large cloud storage.
Key Generation Phase
Key generation is an important part in secure data sharing in cloud. Public
Key Cryptography (PKC) uses separate keys for encryption and decryption.
Executed by the data owner to randomly generate a public/master-secret key pair
(pk, msk). The sender will encrypt the message data with public key and receiver
will decrypt with master key.
Data Encryption
To provide secure data storage, the data needs to be encrypted. In KAC, users
encrypt a message not only under a public-key, but also under an identifier of cipher-
text called class. This phase is executed by anyone who wants to send the encrypted
data. Encrypt (pk, m, i), the encryption algorithm takes input as public parameters
pk, a message m, and i denoting cipher text class. The algorithm encrypts message
m and produces a cipher text C that satisfies the access structure is able to decrypt
the message Input= public key pk, an index i, and message m .Output = cipher text
C.
Extraction
This algorithm is run by the data owner to generate an aggregate searchable
encryption key for delegating the keyword search right for a certain set of documents
to other users. It takes as input the owner’s master-secret key msk and a set S which
contains the indices of documents, then outputs the aggregate key
Trapdoor
This algorithm using this aggregate key, and submit the trapdoor to the cloud.
After receiving the trapdoor, to perform the keyword search over the specified set of
documents. It takes as input the aggregate searchable encryption key and a keyword
w, then outputs only one trapdoor.
Adjust
This algorithm is run by cloud server to adjust the aggregate trapdoor to
generate the right trapdoor for each different document. It takes as input the system
public parameters params, the set S of documents’ indices, the index i of target
document and the aggregate trapdoor Tr, then outputs each trapdoor Tri for the i-th
target document in S.
Test & Decryption
This algorithm is run by the cloud server to perform keyword search over an
encrypted document. It takes as input the trapdoor Tri and the document index i, then
outputs true or false to denote whether the document doci contains the keyword w.
Then user with an aggregate key can decrypt these encrypted photos any cipher-text
provided that the cipher-text’s class is contained. Decryption key more powerful in
the sense that it allows decryption of multiple cipher text.
4. SYSTEM ANALYSIS AND SYSTEM DESIGN
Assuming that a new system is to be developed, the next phase is system analysis.
Analysis involved a detailed study of the current system, leading to specifications of
a new system. Analysis is a detailed study of various operations performed by a
system and their relationships within and outside the system. During analysis, data
are collected on the available files, decision points and transactions handled by the
present system. Interviews, on-site observation and questionnaire are the tools used
for system analysis.
Public key
Encrypt (PK, i, m) CT
Input= Public Key PK, File Index i and Message m
Output = Ciphertext CT
Extract(msk, S) Kagg
Input= Master Key msk, S subset of indices of documents
Output = Aggregate key Kagg
Trapdoor(Kagg,w) Tr
Input= Aggregate key Kagg, keyword w
Output = one trapdoor Tr
Test(Tri, i) True/False, m
Input= Adjusted trapdoor Tri, document i
Output = True/False, message m
4.2.2 DATA FLOW DIAGRAM
Data Flow Diagram shows the flow of data or information. It can be partitioned
into single processes or functions. The DFD is an excellent communication tool
for analysts to model processes and functional requirements. Used effectively, it
is a useful and easy to understand modeling tool. It has broad application and
usability across most software development projects. It is easily integrated with
data modeling, workflow modeling tools, and textual specs. Together with these,
it provides analysts and developers with solid models and specs. Alone, however,
it has limited usability. It is simple and easy to understand by users. And can be
easily extended and refined with further specification into a physical version for
the design and development teams. The symbols used to prepare DFD do not
imply a physical implementation, a DFD can be considered to an abstract of the
logic of an information-oriented or a process-oriented system flow-chart.
DFD LEVEL 0
Encrypted Request
Data
Cloud
Data Owner User
Server
Reply
Network
Storage
DFD Level 1
Data Owner
Initialize System
Parameter
Key Generation
Upload CT to
Server
Multi-Key SE
Extract Key
Generate Aggregate
key
Fig : Multi-Key SE
DFD Level 3
Data User
Generate Keyword
trapdoor
Login
This table is used to save the security information in which it can be retrieved for
future reference and also update whenever required.
Profile
This table is used to save the profile information in which it can be retrieved
for future reference and also update whenever required.
Request
This table is used to save the request information in which it can be retrieved
for future reference and also update whenever required.
Friends
This table is used to save the friends information in which it can be retrieved
for future reference and also update whenever required.
For correctness
Test for correctness are supposed to verify that a program does exactly what it
was designed to do. This is much more difficult than it may at first appear, especially
for large programs.
Unconventional Testing
Unconventional Testing is done by Quality Assurance team with the reference
of each and every documents starting from initial stage of SDLC. This process
involves verification through walkthrough and inspections to check whether the
development happened as per the company process guidelines or not.
Conventional Testing
Unit Testing
Unit testing focuses verification effort on the smallest unit of software design
– the software component or module. Using the component level design description
as a guide, important control paths are tested to uncover errors within the boundary
of the module. The relative complexity of tests and uncovered scope established for
unit testing. The unit testing is white-box oriented, and step can be conducted in
parallel for multiple components. The modular interface is tested to ensure that
information properly flows into and out of the program unit under test. The local
data structure is examined to ensure that data stored temporarily maintains its
integrity during all steps in an algorithm’s execution. Boundary conditions are tested
to ensure that all statements in a module have been executed at least once. Finally,
all error handling paths are tested.
Tests of data flow across a module interface are required before any other test
is initiated. If data do not enter and exit properly, all other tests are moot. Selective
testing of execution paths is an essential task during the unit test. Good design
dictates that error conditions be anticipated and error handling paths set up to reroute
or cleanly terminate processing when an error does occur. Boundary testing is the
last task of unit testing step. Software often fails at its boundaries.
Unit testing was done in Sell-Soft System by treating each module as separate
entity and testing each one of them with a wide spectrum of test inputs. Some flaws
in the internal logic of the modules were found and were rectified.
Integration Testing
Validation Testing
This is the final step in testing. In this the entire system was tested as a whole
with all forms, code, modules and class modules. This form of testing is popularly
known as Black Box testing or System testing.
Acceptance Testing
Testing generally involves running a suite of tests on the completed system.
Each individual test, known as a case, exercises a particular operating condition of
the user's environment or features of the system, and will result in a pass or fail,
or outcome. There is generally no degree of success or failure. The test environment
is usually designed to be identical, or as close as possible, to the anticipated user's
environment, including extremes of such. These test cases must each be
accompanied by test case input data or a formal description of the operational
activities (or both) to be performed—intended to thoroughly exercise the specific
case—and a formal description of the expected results.
6. SOURCE CODE
1. Create Account
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class frmreg : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DateTime dt;
dt = DateTime.Now;
Label2.Text = dt.ToString("dd/MM/yyyy");
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("select uname from reg where
uname='" + TextBox6.Text + "'", con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count != 0)
{
}
}
protected void Button2_Click(object sender, EventArgs e)
{
DropDownList1.ClearSelection();
DropDownList2.ClearSelection();
TextBox2.Text = "";
TextBox3.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox1.Text = "";
}
private void indata()
{
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("insert into
reg(Name1,Gender,Country,Email_ID,Uname,Pass1,date1)values('" +
TextBox2.Text + "','" + DropDownList1.SelectedValue + "','" +
DropDownList2.SelectedValue + "','" + TextBox3.Text + "','" + TextBox6.Text +
"','" + TextBox7.Text + "','" + Label2.Text + "')", con);
OleDbCommand cmd1 = new OleDbCommand("insert into
profile(uname,name1,image1)values('" + TextBox6.Text + "','" + TextBox2.Text +
"','Photo.jpg')", con);
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
DropDownList1.ClearSelection();
DropDownList2.ClearSelection();
TextBox2.Text = "";
TextBox3.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox1.Text = "";
Server.Transfer("Default.aspx");
}
private void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'>" + Environment.NewLine +
"window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
}
2. Login page
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("select Uname,Pass1 from reg
where Uname='" + TextBox1.Text + "' and Pass1='" + TextBox2.Text + "'", con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count != 0)
{
Session["user"] = TextBox1.Text;
Server.Transfer("frmhome.aspx");
}
else
{
MessageBox("Invalid UserName or Password");
}
}
private void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'>" + Environment.NewLine +
"window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
}
3. Profile Information
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class frmprofile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null)
{
Server.Transfer("Default.aspx");
}
else
{
if (!IsPostBack)
{
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("Select
qual,desg,address1,phno1,image1 from profile where uname='" +
Session["user"].ToString() + "'", con);
// OleDbCommand cmd = new OleDbCommand("Select
qual,desg,address1,phno1,image1 from profile",con);
OleDbDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
DropDownList1.SelectedValue = dr["qual"].ToString();
DropDownList2.SelectedValue = dr["desg"].ToString();
TextBox2.Text = dr["address1"].ToString();
TextBox1.Text = dr["phno1"].ToString();
FileUpload1.Equals(dr["image1"].ToString());
}
dr.Close();
con.Close();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string dd = null;
string _fileExt = null;
dd = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
_fileExt = System.IO.Path.GetExtension(dd);
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("update profile set qual='"
+ DropDownList1.SelectedValue + "',desg='" + DropDownList2.SelectedValue +
"',image1='" + dd + "',status1='0',status2='0' where uname='" +
Session["user"].ToString() + "'", con);
OleDbCommand cmd1 = new OleDbCommand("update profile set
address1='" + TextBox2.Text.Trim() + "',phno1='" + TextBox1.Text.Trim() + "'
where uname='" + Session["user"].ToString() + "'", con);
OleDbCommand cmd2 = new OleDbCommand("update friends set
image2='" + dd + "' where uname2='" + Session["user"].ToString() + "'", con);
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
FileUpload1.PostedFile.SaveAs(Server.MapPath(".//Photo//") + dd);
con.Close();
Server.Transfer("frmprofile.aspx");
}
private void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'>" + Environment.NewLine +
"window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Drawing;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.IO;
public partial class frmupload : System.Web.UI.Page
{
double myID;
string str;
static string loadImage = "";
static string f_encmsg = "";
int m_Ji, n_Ji;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null)
{
Server.Transfer("Default.aspx");
}
else
{
if (!IsPostBack)
{
fillgrid1();
txtfill();
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
string dd = null;
string _fileExt = null;
dd = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
_fileExt = System.IO.Path.GetExtension(dd);
if (_fileExt == ".jpg" || _fileExt == ".bmp" || _fileExt == ".png" || _fileExt ==
".jpeg")
{
FileInfo fi = new FileInfo(Server.MapPath(".//files//") + dd);
System.Drawing.Image UploadedImage =
System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
//Determine width and height of uploaded image
Image1.ImageUrl = "~/files/" + dd;
float UploadedImageWidth = UploadedImage.PhysicalDimension.Width;
float UploadedImageHeight = UploadedImage.PhysicalDimension.Height;
Label2.Text = fi.Name;
double imageMB = ((fi.Length / 1024f) / 1024f);
Label3.Text = UploadedImageHeight + " X " + UploadedImageWidth;
Label4.Text = imageMB.ToString(".##") + "MB";
}
else
{
MessageBox("Invalid Image Format");
}
}
protected void DataList1_ItemCommand(object source,
DataListCommandEventArgs e)
{
}
private void encdec()
{
txtfill();
string dd = null;
dd = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
FileInfo fi = new FileInfo(Server.MapPath(".//Photo//") + dd);
System.Drawing.Image UploadedImage =
System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
//Determine width and height of uploaded image
float UploadedImageWidth = UploadedImage.PhysicalDimension.Width;
float UploadedImageHeight = UploadedImage.PhysicalDimension.Height;
//TextBox4.Text = "File Name: " + fi.Name;
double imageMB = ((fi.Length / 1024f) / 1024f);
//TextBox4.Text = "Image Resolution: " + UploadedImageHeight + " X " +
UploadedImageWidth;
//TextBox4.Text = "Image Size: " + imageMB.ToString(".##") + "MB";
loadImage = BitConverter.ToString(ConvertImageToByte(UploadedImage));
File.WriteAllText("C:\\test.txt", loadImage);
//Encyption================
int P = Convert.ToInt32(TextBox3.Text);
int Q = Convert.ToInt32(TextBox5.Text);
m_Ji = Su_Ji(P, Q);
n_Ji = Phi_Ji(P, Q);
char[] Ming;
Ming = loadImage.ToCharArray();
foreach (char c in Ming)
{
string ming;
int Ming_Num = J_Mi((int)c, Get_e(n_Ji), m_Ji);
Char[] Ming_Char = Ming_Num.ToString().ToCharArray();
if (Ming_Char.GetLength(0) == 1)
{
ming = "000" + Ming_Char[0].ToString();
Ming_Char = ming.ToCharArray();
}
if (Ming_Char.GetLength(0) == 2)
{
ming = "00" + Ming_Char[0].ToString() + Ming_Char[1].ToString();
Ming_Char = ming.ToCharArray();
}
if (Ming_Char.GetLength(0) == 3)
{
ming = "0" + Ming_Char[0].ToString() + Ming_Char[1].ToString() +
Ming_Char[2].ToString();
Ming_Char = ming.ToCharArray();
}
string[] Siyao_Num;
TextBox2.Text += Ming_char.ToString();
i = i + 4;
}
File.WriteAllText("C:\\test2.txt", TextBox2.Text);
//Convert to image====
string linetotext1 = File.ReadAllText("C:\\test2.txt");
System.Drawing.Image UploadedImage1 =
ConvertByteToImage(DecodeHex(linetotext1));
UploadedImage1.Save("C:\\Img.jpg",
System.Drawing.Imaging.ImageFormat.Jpeg);
}
public static byte[] DecodeHex(string hextext)
{
String[] arr = hextext.Split('-');
byte[] array = new byte[arr.Length];
for (int i = 0; i < arr.Length; i++)
array[i] = Convert.ToByte(arr[i], 16);
return array;
}
public static Bitmap ConvertByteToImage(byte[] bytes)
{
return (new Bitmap(System.Drawing.Image.FromStream(new
MemoryStream(bytes))));
}
public static byte[] ConvertImageToByte(System.Drawing.Image My_Image)
{
MemoryStream m1 = new MemoryStream();
new Bitmap(My_Image).Save(m1,
System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] header = new byte[] { 255, 216 };
header = m1.ToArray();
return (header);
}
public void fillgrid1()
{
}
private void txtfill()
{
OleDbConnection con;
string strConnString =
ConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString;
con = new OleDbConnection(strConnString);
con.Open();
OleDbCommand cmd = new OleDbCommand("select max(idno) as idno from
adphoto where uname='" + Session["user"].ToString() + "'", con);
OleDbDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
string strid = dr["idno"].ToString();
if (strid == "")
{
str= "1";
TextBox1.Text = "1";
}
else
{
myID = Convert.ToDouble(dr["idno"]) + 1;
str = myID.ToString();
TextBox1.Text = myID.ToString(); ;
}
}
dr.Close();
con.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
int P = Convert.ToInt32(TextBox3.Text);
int Q = Convert.ToInt32(TextBox5.Text);
if (!IsPrime(P))
{
MessageBox("Enter Prime Number:P");
}
else if (!IsPrime(Q))
{
MessageBox("Enter Prime Number:Q");
}
else
{
m_Ji = Su_Ji(P, Q);
n_Ji = Phi_Ji(P, Q);
TextBox4.Text = Get_e(n_Ji) + "," + m_Ji;
TextBox6.Text = Get_d(n_Ji, Get_e(n_Ji)) + "," + m_Ji;
}
}
catch (Exception ex) {
MessageBox("Enter Number Only");
}
}
private int Su_Ji(int m, int n)
{
int t;
t = m * n;
return t;
}
private int Phi_Ji(int m, int n)
{
int t;
t = (m - 1) * (n - 1);
return t;
}
private bool phi(int Num)
{
bool flag = true;
for (int start = 2; start < (Num / 2); start++)
{
if (Num % start == 0)
{
flag = false;
break;
}
}
return flag;
}
private void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'>" + Environment.NewLine +
"window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
private int Get_e(int m)
{
m = m - 1;
int start = m;
if (phi(m))
{
start = m;
}
else
{
for (start = 2; start < m / 2; start++)
{
if (m % start == 0)
{
break;
}
}
}
return start;
}
}
protected void Button5_Click(object sender, EventArgs e)
{
if (TextBox7.Text == "")
{
MessageBox("Enter Image to byte data");
}
else
{
//Encyption================
int P = Convert.ToInt32(TextBox3.Text);
int Q = Convert.ToInt32(TextBox5.Text);
m_Ji = Su_Ji(P, Q);
n_Ji = Phi_Ji(P, Q);
char[] Ming;
Ming = loadImage.ToCharArray();
string encmsg = "";
foreach (char c in Ming)
{
string ming;
int Ming_Num = J_Mi((int)c, Get_e(n_Ji), m_Ji);
Char[] Ming_Char = Ming_Num.ToString().ToCharArray();
if (Ming_Char.GetLength(0) == 1)
{
ming = "000" + Ming_Char[0].ToString();
Ming_Char = ming.ToCharArray();
}
if (Ming_Char.GetLength(0) == 2)
{
ming = "00" + Ming_Char[0].ToString() + Ming_Char[1].ToString();
Ming_Char = ming.ToCharArray();
}
if (Ming_Char.GetLength(0) == 3)
{
ming = "0" + Ming_Char[0].ToString() + Ming_Char[1].ToString() +
Ming_Char[2].ToString();
Ming_Char = ming.ToCharArray();
}
foreach (char m in Ming_Char)
{
encmsg += m;
}
}
f_encmsg = encmsg + "-" + TextBox1.Text;
TextBox2.Text = f_encmsg;
}
protected void Button6_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
}
}
7. SCREENSHOTS
Member Registration
Home page
View Profile
Friends List
System Initalization and Key Generation
Data Encryption
Encrypted Files
Key Request
Extraction