REVERSIBLE DATA HIDING IN ENCRYPTED IMAGES BY RESERVING ROOM BEFORE ENCRYPTION
REVERSIBLE DATA HIDING IN ENCRYPTED IMAGES BY RESERVING ROOM BEFORE ENCRYPTION
ABSTRACT
Recently, more and more attention is paid to reversible data hiding (RDH) in encrypted images, since it maintains the excellent property that the original cover can be losslessly recovered after embedded data is extracted while protecting the image content’s confidentiality. All previous methods embed data by reversibly vacating room from the encrypted images, which may be subject to some errors on data extract ion and/or image restoration. In this paper, we propose a novel method by reserving room before encryption with a traditional RDH algorithm, and thus it is easy for the data hider to reversibly embed data in the encrypted image. The proposed method can achieve real reversibility, that is, data extraction and image recovery are free of any error. Experiments show that this novel method can embed more than 10 times as large payloads for the same image quality as the previous methods, such as for PSNR dB.
Architecture
Existing System
In this Existing System, since losslessly vacating room from the encrypted images is relatively difficult and sometimes inefficient, why are we still so obsessed to find novel RDH techniques working directly for Encrypted Images? The method in compressed the encrypted LSBs to vacate room for additional data by finding syndromes of a parity-check matrix, and the side information used at the receiver side is also the spatial correlation of decrypted images. All the three methods try to vacate room from the encrypted images directly. However, since the entropy of encrypted images has been maximized, these techniques can only achieve small payloads generate marked image with poor quality for large payload and all of them are subject to some error rates on data extraction and/or image restoration.
Disadvantage
X. Low error rate
X. Data extraction and image restoration problem
Proposed System
In proposed method can achieve real reversibility, that is, data extraction and image recovery are free of any error. If we reverse the order of encryption and vacating room, i.e., reserving room prior to image encryption at content owner side, the RDH tasks in encrypted images would be more natural and much easier which leads us to the novel framework, “reserving room before encryption (RRBE)”
Advantage
Not only does the proposed method separate data extraction from image decryption but also achieves excellent performance in two different prospects:
Real reversibility is realized, that is, data extraction and image recovery are free of any error.
For given embedding rates, the PSNRs of decrypted image containing the embedded data are significantly improved; and for the acceptable PSNR, the range of embedding rates is greatly enlarged.
Modules
1. Encrypted Image Generation
a) IMAGE PARTITION
b) SELF REVERSIBLE EMBEDDING
2. Data Hiding In Encrypted Image
3. Data Extraction and Image Recovery
4. Data Extraction and Image Restoration
Modules Description
Encrypted Image Generation
In this module, to construct the encrypted image, the first stage can be divided into three steps:
c) IMAGE PARTITION,
d) SELF REVERSIBLE EMBEDDING followed by image encryption.
At the beginning, image partition step divides original image into two parts and then, the LSBs of are reversibly embedded into with a standard RDH algorithm so that LSBs of can be used for accommodating messages; at last, encrypt the rearranged image to generate its final version.
a) IMAGE PARTITION
The operator here for reserving room before encryption is a standard RDH technique, so the goal of image partition.
b) SELF REVERSIBLE EMBEDDING
The goal of self-reversible embedding is to embed the LSB-planes of into by employing traditional RDH algorithms. We simplify the method in to demonstrate the process of self-embedding.
Data Hiding In Encrypted Image
In this module, a content owner encrypts the original image using a standard cipher with an encryption key. After producing the encrypted image, the content owner hands over it to a data hider (e.g., a database manager) and the data hider can embed some auxiliary data into the encrypted image by losslessly vacating some room according to a data hiding key. Then a receiver, maybe the content owner himself or an authorized third party can extract the embedded data with the data hiding key and further recover the original image from the encrypted version according to the encryption key.
Data Extraction and Image Recovery
In this module, Extracting Data from Encrypted Images to manage and update personal information of images which are encrypted for protecting clients’ privacy, an inferior database manager may only get access to the data hiding key and have to manipulate data in encrypted domain. When the database manager gets the data hiding key, he can decrypt and extract the additional data by directly reading the decrypted version. When requesting for updating information of encrypted images, the database manager, then, updates information through LSB replacement and encrypts up dated information according to the data hiding key all over again. As the whole process is entirely operated on encrypted domain, it avoids the leakage of original content.
Data Extraction and Image Restoration
In this module, after generating the marked decrypted image, the content owner can further extract the data and recover original image.
Reversible Data Hiding (RDH) – Compression Algorithm
private void Encrypt_btn_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(EnImage_tbx.Text);
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
saveToImage = saveFileDialog1.FileName;
}
else
return;
if (EnImage_tbx.Text == String.Empty || EnFile_tbx.Text == String.Empty)
{
MessageBox.Show(“Encrypton information is incomplete!\nPlease complete them frist.”, “Error”, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (8 * ((height * (width / 3) * 3) / 3 – 1) < fileSize + fileNameSize)
{
//MessageBox.Show("File size is too large!\nPlease use a larger image to hide this file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//return;
}
fileContainer = File.ReadAllBytes(loadedFilePath);
EncryptLayer();
//SqlConnection con = new SqlConnection(constring);
//con.Open();
//SqlCommand cmd2 = new SqlCommand("update Embedding set saveimagepath='" + saveToImage + "' where id1='" + int2 + "' and autid='" + auid1 + "'", con);
//cmd2.ExecuteNonQuery();
//SqlCommand cmd1 = new SqlCommand("update Embedding set loadimagepath='" + EnImage_tbx.Text + "',loadfilepath='" + EnFile_tbx.Text + "' where id1='" + int2 + "' and autid='" + auid1 + "'", con);
//cmd1.ExecuteNonQuery();
//con.Close();
//MessageBox.Show("your file is ready to split the packets ,click packets sending!!!");
}
private void EncryptLayer()
{
toolStripStatusLabel1.Text = "Encrypting... Please wait";
Application.DoEvents();
long FSize = fileSize;
Bitmap changedBitmap = EncryptLayer(8, loadedTrueBitmap, 0, (height * (width / 3) * 3) / 3 - fileNameSize - 1, true);
FSize -= (height * (width / 3) * 3) / 3 - fileNameSize - 1;
if (FSize > 0)
{
for (int i = 7; i >= 0 && FSize > 0; i–)
{
changedBitmap = EncryptLayer(i, changedBitmap, (((8 – i) * height * (width / 3) * 3) / 3 – fileNameSize – (8 – i)), (((9 – i) * height * (width / 3) * 3) / 3 – fileNameSize – (9 – i)), false);
FSize -= (height * (width / 3) * 3) / 3 – 1;
}
}
changedBitmap.Save(saveToImage);
toolStripStatusLabel1.Text = “Encrypted image has been successfully saved.”;
EncriptionDone = true;
AfterEncryption = Image.FromFile(saveToImage);
this.Invalidate();
}
private Bitmap EncryptLayer(int layer, Bitmap inputBitmap, long startPosition, long endPosition, bool writeFileName)
{
Bitmap outputBitmap = inputBitmap;
layer–;
int i = 0, j = 0;
long FNSize = 0;
bool[] t = new bool[8];
bool[] rb = new bool[8];
bool[] gb = new bool[8];
bool[] bb = new bool[8];
Color pixel = new Color();
byte r, g, b;
if (writeFileName)
{
FNSize = fileNameSize;
string fileName = justFName(loadedFilePath);
//write fileName:
for (i = 0; i < height && i * (height / 3) < fileNameSize; i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) + (j / 3) < fileNameSize; j++)
{
byte2bool((byte)fileName[i * (height / 3) + j / 3], ref t);
pixel = inputBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
rb[7] = t[0];
gb[7] = t[1];
bb[7] = t[2];
}
else if (j % 3 == 1)
{
rb[7] = t[3];
gb[7] = t[4];
bb[7] = t[5];
}
else
{
rb[7] = t[6];
gb[7] = t[7];
}
Color result = Color.FromArgb((int)bool2byte(rb), (int)bool2byte(gb), (int)bool2byte(bb));
outputBitmap.SetPixel(j, i, result);
}
i--;
}
//write file (after file name):
int tempj = j;
for (; i < height && i * (height / 3) < endPosition - startPosition + FNSize && startPosition + i * (height / 3) < fileSize + FNSize; i++)
for (j = 0; j < (width / 3) * 3 && i * (height / 3) + (j / 3) < endPosition - startPosition + FNSize && startPosition + i * (height / 3) + (j / 3) < fileSize + FNSize; j++)
{
if (tempj != 0)
{
j = tempj;
tempj = 0;
}
byte2bool((byte)fileContainer[startPosition + i * (height / 3) + j / 3 - FNSize], ref t);
pixel = inputBitmap.GetPixel(j, i);
r = pixel.R;
g = pixel.G;
b = pixel.B;
byte2bool(r, ref rb);
byte2bool(g, ref gb);
byte2bool(b, ref bb);
if (j % 3 == 0)
{
rb[layer] = t[0];
gb[layer] = t[1];
bb[layer] = t[2];
}
else if (j % 3 == 1)
{
rb[layer] = t[3];
gb[layer] = t[4];
bb[layer] = t[5];
}
else
{
rb[layer] = t[6];
gb[layer] = t[7];
}
Color result = Color.FromArgb((int)bool2byte(rb), (int)bool2byte(gb), (int)bool2byte(bb));
outputBitmap.SetPixel(j, i, result);
}
long tempFS = fileSize, tempFNS = fileNameSize;
r = (byte)(tempFS % 100);
tempFS /= 100;
g = (byte)(tempFS % 100);
tempFS /= 100;
b = (byte)(tempFS % 100);
Color flenColor = Color.FromArgb(r, g, b);
outputBitmap.SetPixel(width - 1, height - 1, flenColor);
r = (byte)(tempFNS % 100);
tempFNS /= 100;
g = (byte)(tempFNS % 100);
tempFNS /= 100;
b = (byte)(tempFNS % 100);
Color fnlenColor = Color.FromArgb(r, g, b);
outputBitmap.SetPixel(width - 2, height - 1, fnlenColor);
return outputBitmap;
}
private void byte2bool(byte inp, ref bool[] outp)
{
if (inp >= 0 && inp <= 255)
for (short i = 7; i >= 0; i–)
{
if (inp % 2 == 1)
outp[i] = true;
else
outp[i] = false;
inp /= 2;
}
else
throw new Exception(“Input number is illegal.”);
}
private byte bool2byte(bool[] inp)
{
byte outp = 0;
for (short i = 7; i >= 0; i–)
{
if (inp[i])
outp += (byte)Math.Pow(2.0, (double)(7 – i));
}
return outp;
}
private string justFName(string path)
{
string output;
int i;
if (path.Length == 3) // i.e: “C:\\”
return path.Substring(0, 1);
for (i = path.Length – 1; i > 0; i–)
if (path[i] == ‘\\’)
break;
output = path.Substring(i + 1);
return output;
}
private string justEx(string fName)
{
string output;
int i;
for (i = fName.Length – 1; i > 0; i–)
if (fName[i] == ‘.’)
break;
output = fName.Substring(i + 1);
return output;
}
SYSTEM REQUIREMENT SPECIFICATION
HARDWARE REQUIREMENTS
• System : Pentium IV 2.4 GHz.
• Hard Disk : 80 GB.
• Monitor : 15 VGA Color.
• Mouse : Logitech.
• Ram : 512 MB.
SOFTWARE REQUIREMENTS
• Operating system : Windows 7 Ultimate (32-bit) OS
• Front End : Visual Studio 2010
• Coding Language : C#.NET
• Database : SQL Server 2008
Comments are closed.