Steganography Project
-
Upload
uttam-jain -
Category
Documents
-
view
23.894 -
download
30
Transcript of Steganography Project
PROJECT REPORTon
SECURITY EXTENSIBILITY INSTEGANOGRAPHY
submitted in partial fulfillment of the requirementsfor the award of the degree of
BACHELOR OF TECHNOLOGY(INFORMATION TECHNOLOGY)
of
UNIVERSITY OF MADRAS
by
MADHAN. R (9002164)RAJESHKUMAR. M (9002176)SWAMYNATHAN. S (9002196)
under the guidance ofMs. CHENTHILBANU,M.E.,
( Lecturer,Departmentof InformationTechnology)
APRIL 2004
DEPARTMENT OF INFORMATION TECHNOLOGY
S.R.M. ENGINEERING COLLEGES.R.M. Nagar, Kattankulathur, Kancheepuram District - 603 203.
BONAFIDE CERTIFICATE
This is to certify that the project work entitled
SECURITY EXTENSIBILITY IN
STEGANOGRAPHY is a bonafide work done by
the requirementsfor the award of the degree of
Bachelor of Technology
.In
INFORMATION TECHNOLOGY
Hea~epartmenl
Submitted for university examination held in April 2004 at
S.R.M. Engineering College, Kattankulathur.
Date:l4 - .; - .l""~ ,nte4ner
60/External Examiner
---- - -
ACKNOWLEDGEMENT
They say, "Rome was not built in a day". Persistence, commitment, and sincerity have
indeed contributed to the successful completion of our final year project 'Security
Extensibility in Steganography'. But without the support and encouragement of many,
our efforts would have gone meaningless.
We first and foremost thank the Almighty for our project's success.
We extend our gratitude to our respected chairman Mr. Pachamuthu, Principal Prof.
R.Venkatramani and our Director Dr. T.P.Ganesan for the infrastructure they have
provided us with and which has been conducive to our pursuits.
We are extremely grateful to the Head of the Department of Information Technology,
Prof. S.Rajendran for having supported and encouraged us all along.
We are profoundly obliged to our project coordinator and Senior Lecturer, Department of
Information Technology, Mrs G.Vadivu, for being the 'backing force' without which we
would not have been motivate enough.
Our very special thanks go to our guide and Lecturer of Department of Information
Technology, Ms ChenthilBanu M.E without whose constant help, suggestions and
advice, we would not have come this far.
We owe a lot to Mr.S.Ashok and Mrs.Vadivu for suggesting improvements and
enhancements.
Weare also greatly indebted to our parents and friends for their moral support and the
whole Information Technology department for all the encouragement.
Last but not the least, the experiences of working together were not only enjoyable but
also very beneficial.
ABSTRACT
Steganography is the art of passing the infonnation in the manner that the very existence of the
message is unknown. The goal of steganography is to avoid suspicion to the transmission of
hidden message, such that it is highly secured. Steganography is the art of concealing the
existence of infonnation within seemingly innocuous carriers. Steganography can be viewed as
akin to cryptography. Both have been used throughout recorded history as means to protect
infonnation. At times these two technologies seem to converge while the objectives of the two
differ. Cryptographic techniques "scramble" messages so if intercepted, the messages cannot be
understood. Steganography, in an essence, "camouflages" a message to hide its existence and
make it seem "invisible" thus concealing the fact that a message is being sent altogether.
Steganography has its place in security. It is not intended to replace cryptography but supplement
it. Hiding a message with steganography methods reduces the chance of a message being
detected. One of the most commonly used methods is Least Significant Bit (LSB) algorithm. This
deals with the embedding of message along with the image file where each pixel is of size 3
bytes. Each and every bit of the message is taken and is embedded along with the bytes of the
image file such that, its inclusion does not make a perceivable change in the message embedded
file. Incase of confidential infonnation that should be sent, provision of security is an inevitable
issue which cannot have any compromise. This algorithm that is commonly used in this field has
a major loophole. That is the ease of cracking the messages that is hidden in the image file. This
is due to the simplicity of the algorithm that gave room for the easy cracking of the messages.
Thus the Security Extensibility algorithms called SRM algorithms for steganography,
cryptography, password authentication, digital watennarking which is developed by our own is
used to provide more security such that the cracking is made quite tough which is almost
improbable.
--- --- - -
..
r- -'11--'
SECURITYEXTENSIBILITYINSTEGANOGRAPHY
I INTRODUCTION
Synopsis
Existing Systems
Background
LSB
Drawbacks of Existing Systems
Need for new system
Proposed system
II SYSTEMANALYSIS
Study of Components:Sender side
Receiver side
SRM algorithm for steganography
SRM algorithm for cryptography
SRM algorithm for Password
Authentication
1
2
3
5
12
12
13
14
15
15
18
21
SRM algorithm for Watermarking 22
Functional Requirements 25. Emedding(LSB). Extracting(LSB). Embedding(SRM algo). . Extracting(SRMalgo)
System Requirements 32. Hardware Requirements. Software Requirements
III SYSTEMDESIGN
SECURITYEXTENSIBILITYINSTEGANOGRAPHY
System Architecture
Program Modules
33
34
Algorithms 45
. LSB algorithm
. SRM algorithm for embedding
. SRM algorithm for Extraction
. SRM algorithm for Encrypting
. SRM algorithm for decrypting
. SRM algorithm for authenticity
. SRM algo for Watennarking
System Testing and snapshots 58
Test Case Design 75
IV CONCLUSION
Advantages
Future Enhancements
Applications
V REFERENCE
75
76
77
78
VI APPENDIX 80
Sample Code
---
. Encrypting
. Decrypting
. Authentication
. Watennarking
Introduction:
Synopsis:
Steganography is the art of passing the information in the manner that the very existence of the
message is unknown. The goal of steganography is to avoid suspicion to the transmission of
hidden message, such that it is highly secured. Steganography is the art of concealing the
existence of information within seemingly innocuous carriers. Steganography can be viewed as
akin to cryptography. Both have been used throughout recorded history as means to protect
information. At times these two technologies seem to converge while the objectives of the two
differ. Cryptographic techniques "scramble" messages so if intercepted, the messages cannot be
understood. Steganography, in an essence, "camouflages" a message to hide its existence and
make it seem "invisible" thus concealing the fact that a message is being sent altogether.
Steganography has its place in security. It is not intended to replace cryptography but supplement
it. Hiding a message with steganography methods reduces the chance of a message being
detected. One of the most commonly used methods is Least Significant Bit (LSB) algorithm.
This deals with the embedding of message along with the image file where each pixel is of size 3
bytes. Each and every bit of the message is taken and is embedded along with the bytes of the
image file such that, its inclusion does not make a perceivable change in the message embedded
file.
Incase of confidential information that should be sent, provision of security is an
inevitable issue which cannot have any compromise. This algorithm that is commonly used in
this field has a major loophole. That is the ease of cracking the messages that is hidden in the
image file. This is due to the simplicity of the algorithm that gave room for the easy cracking of
the messages. Thus the Security Extensibility Algorithm is developed and can be implemented
which provides a good security comparing to this LSB algorithm.
page 1
Embedding of the messages in a 24-bit color image, is fully dependent on the
algorithm used and the security of the hidden image from being retrieved by some enigmatic
person is the main factor to be focused
Many concepts that enhance the security of the message transfer is used.
They are
1. Use of digital watermarking.
2. Use of Cryptography(algorithm developed by our own)
3. Ability to send more than one message file in the same image
file.
4 .password authentication
Existing Systems:
The existing system algorithm in steganography is LSB algorithm. This means Least Significant
Bit algorithm. This steganography entered into the computer technologies during the hours of
september 11 incidents by Osama Ben Laden.. But before that it was resident and was used for
secured communication of messages outside computer technology. Some of the examples are
1. Text hidden on wax tablets
2. Null ciphers
Example: Message sent by a German spy in world war II
Apparently neutral's protest is thoroughly discounted and igllored. Isman hard
hit. Blockage issue affects the pretext embargo on products, ejecting suets and vegetable oils.
page 2
Exact answer is found by choosing only the second letters of each and every word. The answer
would be
Perishing sailsfrom NY June 1.
Back GroUlld:
Steganographic software is new and very effective. Such software enables information to
be hidden in graphic, sound and apparently "blank" media. Charles Kurak and John
McHugh discuss the implications of downgrading an image (security downgrading) when
it may contain some other information [Kurak92]. Though not explicitly stated the
author(s) ofStegoDos mention embedding viruses in images [StegoDos].
In the computer, an image is an array of numbers that represent light intensities at various
points (pixelsl) in the image. A common image size is 640 by 480 and 256 colors (or 8
bits per pixel). Such an image could contain about 300 kilobits of data.
There are usually two type of files used when embedding data into an image. The
innocent looking image which will hold the hidden information is a "container." A
"message" is the information to be hidden. A message may be plain-text, cipher text,
other images or any thing that can be embedded in the least significant bits (LSB) of an
Image.
For example:
Suppose we have a 24-bit image 1024 x 768 (this is a common resolution for satellite images,
electronic astral photographs and other high resolution graphics). This may produce a file over 2
megabytes in size (l024x768x24/8 = 2,359,296 bytes). All color variations are derived from
three primary colors, Red, Green and Blue. Each primary color is represented by I byte (8 bits).
24-bit images use 3 bytes per pixel. If information is stored in the least significant bit (LSB) of
each byte, 3 bits can be a stored in each pixel. The "container" image will look identical to the
human eye, even if viewing the picture side by side with the original. Unfortunately, 24-bit
page 3
images are uncommon (with exception of the formats mentioned earlier) and quite large. They
would draw attention to themselves when being transmitted across a network. Compression
would be beneficial if not necessary to transmit such a file. But file compression may interfere
with the storage of information.
As many people think, steganography and cryptography are not same. They are different. They
are differentiated based on the following aspects based on david kahn's thesis.
David Kahn places steganography and cryptography in a table to differentiate against the
types and counter methods used. Here security is defined as methods of "protecting"
information where intelligence is defined as methods of "retrieving" information
[Kahn67]:
[SignalSecurity -ISignal Intelligenc-;
- ----Communication Security .Communication Intelligence
--- -,_.- -.- -
· Traffic security(call-sign changes, dummy:
messages, radio silence)
· Traffic analysis (direction-
finding, message-flow
studies, radio finger printing)
--.--.- --,- - -, - .-
page 4
- - - -. Steganography (invisible inks, open codes,
messages III hollow heels) and . Interception and direction-
Transmission Security (spurt radio and finding
spread spectrum systems)
. Cryptography(codes and ciphers) . Cryptanalysis
Electronic Security Electronic Intelligence
!
. Emission Security (shifting of radar I
frequencies, spread spectrum)
. Electronic Reconnaissance
(eaves-dropping on radar
emissions)
rI
,--r-------
Counter-Countermeasures "looking I .I. Countermeasures (jamming
through" (jammed radar) radar and false radar echoes)
---~-~--- -Table 1: Kahn's Security Table
LSB algorithm:
In LSB algorithm, the message bit is taken from the message byte and then that particular bit
will be embedded inside the least significant bit of an image or video or audio file. This is
done because..
l.The message embedded in the least significant bit of an image file will not draw the
suspicion of the hacker as the minute difference that would be made in the pixel value of the
image file will not be perceived by the normal naked human eye.
2.The message that will be embedded in the LSB of an audio file will not create suspicion to
the hacker as that change would not be perceived by the human ear.
3.The same concept works out evenwith video file.
4.This same algorithm can also be used for digital Watermarking.
page 5
---
The file where we actually embed the message is known as cover file. The usual files that
are selected as cover file are image, audio, video, text data. But using text data as a cover
file will encipher the message than hiding the message. So logically this cannot be told as
steganography.
Implementing Steganography in LSB:-
Steganography can be implemented using LSB algorithm in two ways
(1) Using keys
(2) Without using keys.
Now let us see a small example of how the message will be stored. Consider 8 bytes
of a cover file(say bitmap image).Let the 8 bytes be
11111010
10101010
11110000
01010110
10010010
01101110
page 6
10000100
11000000
Consider a message byte 11111111.we should embed all these 8 Is into the image
file. Since we are going to use the LSB algorithm we need 8 bytes from cover file to
embed a byte of message file. This is done by, covering each and every bit of the
message file by the LSB of the cover file.
The final answer would be
11111011
10101011
11110001
01010111
10010011
01101111
10000101
11000001
The Is with underlining denotes the message bit embedded in the cover file.
page 7
In case of LSB without key , it is nothing but embedding all the message bits in the
successive bytes.
Message tobeembedded.
Message isembeddedinto the LeastSignificantBit of thecoverfile andnow this isan EncodedPicture.
File isDecodedandmessage ISgot
Cover
File(Image,audio, videofiles)
The file size will be embedded as a header in the embedding process itself by the sender
so that it would help the receiver to decode only that particular amount of bytes from the
cover file thereby not wasting time in decoding the bytes that does not have any messages
embedded in it. Another important constraint is the size of the message file should not
be greater than l/Sth of the size of the cover file.
In case of LSB with key, we add an extra key such that based on the key value, the
number of bytes will be traversed. For example after embedding in the LSB, the key
value will be checked and if the key value is n, after n number of bytes the bit will be
embedded. This type of embedding can be done in image file and it was once done using
the digital message that is passing in ISDN phone lines. It was Hiding messages in the
nOIse of ISDN telephone
page 8
conversations.
This can even be explained with a better example by giving the test data and how it will
be encoded. The main thing that should be taken care is the key that is generated in the
sender side that is the stego key generated in the sender side should be generated in the
receiver side to retrieve the message from the cover bytes. Else it would not be possible
for the receiver to decode and at the same time, the number of bytes needed in this case
cannot be determined during the algorithm design time. It is totally dependent on the
stego key and message file size.
Now let us see the exemplification given for this algorithm below. In sender side the key
is generated and based on the key we are embedding the message into the cover bytes and
this is generated again at the receiver side and we uncover the elements from the covered
file.
page 9
Telephone 1: Telephone 2:
Sender: Receiver:
Message is hidden by the The same key isthe lowest bits in generated in thetransferred byte receiver side and the
sequence.Distance distance is found and
between changed bits is then the embedded bit
determined by the is retrieved.
stegokeys.
010101
Fir
Are
page 10
Original Embedded KeyByte MessageSequence(cover)
01010101 0 1
01010101 0 1
01010100 1 0
01001010 0 2
00010100 1 1
11101001 1 0
)1 0101010Q010101000100101Q00010101
t 3 bits getting embedded and key no. of bytes
left un encoded.
Key Embedded Message Cover
1 0 01010101
1 0 0101010*
0 1 01010100
2 0 0100010*
1 1 0001010*
0 1 11101001
How to choose the cover file incase of an image?
The main thing that should considered in choosing an image file as a cover file is the
compression method. There are two types of compression methods.
Lossless Compression (Ex: GIF,BMP)
. Original infonnation remains intact
. Original message can be reconstructed exactly
Lossy Compression (Ex: JPEG)
. yields very good compression
. may not maintain the integrity of the original message
A 24-Bit Bitmap image:
(a) A 24 bit bitmap image is made up of pixels of size 24 bits.
(b) The pixel has 8 bits of Red, Green and blue values respectively
(c ) So the color variations are derived from these 3 primary colors.
(d) Infonnation is stored in the LSB of 3 bytes.
page 11
Drawbacks of the Existing Systems:
Though LSB has the advantages like easy implementations, it also has its unavoidable
drawbacks. Once if the hacker is aware of the presence of message in the cover file, he
will first use the LSB algorithm and so it gives very less security to the message. More
over as the name refers only LSB of the cover byte is used and other bits are not used as
it may create changes in the cover file and it would draw suspicion and tends to easy
steganalysis.
So if a confidential message is expected to send, then it should guarantee full security and
it should make the hacker to consume his/her maximum amount of time hack the content.
Need for new system:
As there is no proper security promise in the LSB algorithm, a new algorithm has been
proposed and designed by us known as S.R.M algorithms which satisfies the following
factors
I.Inability to hack the content immediately
2. Encrypt and Embed
3.Digital Watermarking
page 12
4.Password Authentication
So these aspects stands as a tool for extending the security in the steganography.
Proposed Systems:
As said above this security is reinforced by 4 concepts
1. S.R.M algorithm for Steganography
2. S.R.M algorithm for Cryptography
3. S.R.M algorithm for password authentication
4. Digital Water Marking
Now let us see each and every algorithm in detailed
SENDER
1. WATERMARKING
2.ENCRYPT THEMESSAGE
3.EMBED THE MESSAGE
RECEIVER
l.P ASSWORDAUTHENTICATION
2.WATERMARKINGVERIICATION
3. EXTRACTING THEMESSAGE
4.DECRYPTING THEMESSAGE
page 13
- - - - . . . - . . - -- - .. _ ___ _ ___ h
This is the general structure. Now let us see each and every algorithms and methods.
This system encompasses all the aspects of network security algorithms. The main
concepts of network security is
1.The data should be sent from a recognized sender
2.The data should reach the legitimate receiver.
3.Data Integrity.
So all these three main concepts are implemented. The following is implemented in
our project as
(a) Password authentication.. ..to check for legitimate receiver
(b) Digital Watermarking to verify for the right sender
(c) Cryptography &steganography algorithms.. ...data Integrity
So our proposed system composes all these things.
SYSTEM ANALYSYS:
Study of Components
page 14
Sellderside
Receiver Side:
Extraction ofencryptedmessage fromthe file
1
Plain text Encrypt
-
WaterMark Embed Image withmessage
Embedded &
Encrypted r Password Digitaltext inside Authentication Watermarkingbitmap verificationimagefile.
Decryption of Messagemessage retrievingr
S.R.M Algorithm for Steganography:
Working:
This algorithm is designed by our own which perfonns the following functions:
The user will prompted to give embedding key.
The key that is given by the user will be taken as a seed and a random number will be
generated.
Then that random number will be moded by 8 and the reminder is the chosen bit position.
The message bit will be taken and embedded in that position.
EX:
Let the key that will be given by the user is 23456.
This is taken as a seed to a random function and a random number will be generated and
let that number be 12541.
This 12541 will be moded by 8, 12541%8=5.
So the message bit will be embedded in the first bit.
So how this was made feasible? Doesn't it change the pixel value?
The answer to this main question is an emphatic no. Because let us consider the following
conditions of moded value.
If the moded value is 0 then LSB is used
page 16
If it is not 0 but some value n(where n<8) then that nth bit is seen. If both the message bit
and the nth bit are same(either both should be one or both should be zero),then the bit is
not embedded but that particular nth bit is directly considered as a message bit(as both
the values are same) and LSB is made O(inthis state LSB acts as a flag)
If the nth bit's value and message bit's value are not same then the LSB is made
1(indicating that the message bit is NOT of the nth bit).
Since all the bits are involved and at the same time there wont be a any change in the
pixel value, this would be more secured.
How about key synchronization?
The next question that would be framed in ur mind is about the key synchronization. How
was it possible?
There is a Class called random in JAVA.
We need to create an instance for this like
Random r=new random(seed);
r.nextintO;
This generates a random number in a particular sequence and always returns the same
sequence of numbers for a particular key in any system. So there will not be any problem
if the same key is used.
Ex for its working:
Let the bit position be 5.
Message byte=10101101
page 17
Message bit to be embedded=I
Image byte=IIQIOIII. change the LSB to IIQIOIIQ
The bit to be embedded is I.But the bit in the fifth position is having O.If I is directly
embeded then there will be a human eye perceivable change in the pixel value. To avoid
that what we actually do is we again change the LSB of image byte to llQOll~ This
LSB acts as a flag means, the value of the message bit stored is NOT of the value of the
bit in 5thposition.
Value of the bit in 5thposition is O.
Its NOT value is I.So the message stored is 1.
The same process is used to retrieve the message in the receiver side.
Advantages:
1. Message can not only be embedded in LSB but also in any of the 8 bits.
2. LSB acts as flag at certain circumstances.
3. Choosing of bit message to embed the message is totally randomized.
4. No need for algorithm secrecy.
5. Key secrecy.
6. Any file can be embedded to any file provided the cover file should 8 times
greater than the file that is going to be embedded.
S.R.M Algorithm for Cryptography:-
Working:
This algorithm is designed by our own which performs the following functions:
1.The user will be asked to enter two keys
page 18
(a) Algorithm selection key
(b) Key for Encryption
2. Here 2 main algorithms are developed and 8 more algorithms are developed which
mainly inherits the concepts of the 2 main algorithm there by making a number of 10.
3.The algorithm selection key concept works like this
Enter the algorithm selection key: 213453452789012345
Enter the algorithm Encryption key 12345678
Working of algorithm selection key:
Each and every digit in the algorithm selection key refers to the corresponding algorithm
of the 10 algorithms.
See the sequence
213453452789012345
The message will be encrypted using algorithm 2, then my algorithm 1,then by algorithm
3 ..and at last by algorithm 5.
And the encryption key is used for selecting the bits and inverting there by emulating the
concept of encryption.
page 19
The working of this encryption is best defined by the following diagram.
Let the algorithm sequence be XYZ and let the encrypting key be KEY
Encryption diagram:
(
Decryption:
page 20
Algorithm X is first Algorithm Y will Algorithm Z willused to encrypt the encrypt the message encrypt the text thatmessage file or the that is already is already encryptedplain text using the encrypted by by X and Y usingKEY Algorithm X using KEY.
the same key KEY.
KEY KEY KEY
Algorithm Z is first Algorithm Y will Algorithm X willused to decrypt the decrypt the message decrypt the text thatencrypted file using that is already is already decryptedthe KEY decrypted by by Z and Y using
Algorithm Z using KEY.the same key KEY.
KEY KEY KEY
The detailed description of the algorithm is done in the later part of the program.
Advantages:
I.Dependent on two keys.
2.Though the encrypting key is known, if the algorithm selection is not known then the
message would not be got back.
3.The same holds good on the other way around.
4.The algorithm selection key can be of any size based on the user requirement and
message confidentiality.
5.Usage oflogical pipelining among various algorithms during cryptography.
S.R.M algorithm for password authentication:
This algorithm is designed by our own which performs the following functions:
page 21
......
This will be used in the receiver side to check the authenticity of the receiver. The main
advantage of this algorithm is its resistance to brute force attacks of the password. The
user will be prompted to enter the password which will not be more than 8 characters. If
the user enters the password correctly, then he will be proceeding further. Else he will be
given 2 more chances to enter the password correctly. If he fails to do that then his
session to enter the password will be blocked and a log file will created entering the date
and time details of the password entered.
Consider that the password is "orbit". If user types the password wrongly for 3 times then
a key will be generated.
How this helps?
A log file which captures the system time, system date and the an output denoting
password success/failure. If the password is typed correctly in the first attempt then it
stores as ps(password success), else it does not print anything.
How administrator use this?
The administrator can verify the logfile such that he will be aware of the real hack
that is going on and he can make various arrangements to save based on that.
Advantage:
I.Resistence to bruteforce attacks
page 22
2.Creation oflogfile storing all vital details
Digital Watermarking:
Digital Watermarking is nothing but a way to find whether a message has been
received trom the exact sender.This is verified in the receiver end.
Working:
The signature of the sender is embedded in the cover file which will be regarded as a
separate header will be done.
Then the message should be encrypted and embedded.
The embedded message will reach the destination and first the user at the receiving
side will type the sender name and verify it. If the string matches then he will be
further proceeding with uncovering and deciphering of the messages. Else he will not
be able to do so.
Consider that the sender name is
SRMITES. This will be embedded as a header to the cover file.
The receiver should some know the sender and a legitimate receiver will be knowing
that.After entering the name it will be checked and the process flows based on the
output.
Advantages:
page 23
1. A good method to ensure whether a particular message is from a right sender.
2. No masquerading can be done by a third person by putting wrong watermarking
as the message that is going to be watermarked will be a secret one.
Functional Requirements:
Focusing the project in the aspect of functional requirement, we can split into
following modules.
LSB algorithm
S.R.M algorithm for Embedding (Steganography)
S.R.M algorithm for Extracting (Steganography)
S.R.M algorithm for Encrypting (Cryptography)
S.R.M algorithm for Decrypting (Cryptography)
S.R.M algorithm for Embedding (Watermarking)
S.R.M algorithm for Extracting and verifying (Watermarking)
S.R.M algorithm for password Authentication
Interfaces and Integration
Functions of LSB algorithm:
In our first module, we have just implemented the LSB algorithm which is nothing
but embedding the message bits in the least significant bits of the cover file .In the
implementation of LSB algorithm we have defined the following functions.
page 24
They are
1. A Main function
2. A function to check whether the file which should be embedded is less than 1/Sth
of the size of the cover file.
3. A function which embeds only the header information of the source cover file to
the destination and making it ready to act as a file which holds the contents of
message file.
4. An Embedding function which embeds the message file's contents to the cover
file.
5. An extraction function which extracts the message from the cover file.
Functions Explanation:
First we will be checking the file size of the file that is going to be embedded because
the file can be embedded only if it is lesser than 1/Sthof the size of the cover file. So
in this function we will get the file size of both the cover file and also the message
file.
Then we will be writing the header information to the destination file. That is an
operating system can recognize the type of file by reading the information specified
in its header. In bitmap image the header size is of 54 bytes and if it is a wav file then
it is of 12 bytes. So the first 54bytes(incase of bitmap image) or 12 bytes(in case of
wav file) is taken an directly written to the destination file as soon as it is opened.
Then we will take each and every bit of the message file and embed it into the least
significant bit of the cover file.
During Extraction process we will uncover the bits in the LSB and we will
amalgamate it to reproduce the embedded message.
page 25
Functiolls of SRM algorithm for Stegallography (Embeddillg):
In SRM algorithm for embedding a sequence of lines are written which performs the
following actions. They are
1. The checking of file size which should be embedded.
2. Writing the header
3. Embedding the size of the embedding file into the cover file so that at the
receiver side it would be easy for the receiver to get the size first and uncover the
elements up to that much amount of bytes.
4. Embedding of the message file.
Functions Explallation:
First we will be checking the file size of the file that is going to be embedded because
the file can be embedded only if it is lesser than l/sth of the size of the cover file. So
in this function we will get the file size of both the cover file and also the message
file.
Then we will be writing the header information to the destination file. That is an
operating system can recognize the type of file by reading the information specified
in its header. In bitmap image the header size is of 54 bytes and if it is a wav file then
it is of 12 bytes. So the first 54bytes(incase of bitmap image) or 12 bytes(in case of
wav file) is taken an directly written to the destination file as soon as it is opened.
The file size if embedded into the cover file which acts as a logical header.
page 26
Then we will generate random numbers with the help of random number generators
and then mod that value with 8 and find the bit positions and check the value. If that
value is 0, then normal LSB is used else message bits representing the positions are
returned.
Later the message bits of that positions are embedded and care is taken that only
the value of LSB changes and no other bit value changes. Other than case 0, LSB acts
as a flag.
Functions of SRM algorithm for Steganography(Extracting):
In SRM algorithm for extraction we perform the extracting of the embedded file with
the help of the following functions.
They are
1. Skipping of the header
2. Getting the file size which is embedded during the embedding session.
3. Extracting the text up to the n number of bytes where n is the file size.
4. Writing the message simultaneously while extracting into the same type of file.
Function Explanations:
1. As we already specified that incase of an image file the first 54 bytes will be a
header information, we cannot read it as mostly it will be in unprintable form, if at
page 27
all printable, then it will be in unreadable fonn. After skipping the header file we
will have our file size embedded.
2. Later this file size if taken and stored in a variable and we will start to uncover the
embedded elements and after recovering the embedded 8 bits from the eight bytes
we will decrease the file size by 1.
3. Until the file size reaches 0, we will be extracting the message bits from all bytes.
The random number that is generated in the user side will be generated in the
same sequence such that the exact bit position is found and we will uncover it.
4. Then after uncovering the elements we will write the message into the file of its
type.
Functions of SRM algorithm for Encryption (Cryptography):
SRM algorithm for encryption uses 2 primitive algorithms which are developed by
our own and 8 algorithms which are derived from those 2 algorithms. The detailed
explanation of those 10 algorithms will be given in the ALGORITHMS section. The
main functions that are provided in this module are
1. Getting the text file or any file to get encrypted
2. Getting the algorithm selection key.
3. Getting the key for encryption
4. With the help of algorithm selection key choosing the algorithms fonning a logical
pipelining.
5. Writing the encrypted file parallely into a file.
page 28
Functions Explanation:
1. At first we will be getting the file which should be encrypted. This file can be of
any type.
2. Then we will be getting the algorithm selection key from the user. This can be of
any SIze. It does not have any constraint to the size.
3. Then the encryption key is got from the user using which we will be encrypting
the file.
4. Then each and every character from the algorithm selection key is taken and the
value is noted and the algorithm corresponding to that value is chosen and then
the file is sent as an input to that algorithm. After encrypted with that algorithm
we will be check the next character from the algorithm selection key and then that
value is noted and the file encrypted by the previous algorithm is sent to this
algorithm and this is done up to the length of the string number of times. So this
process in over-all acts as a logical pipelining.
5. Then after encrypting fully the encrypted message is written in a file.
Functions of S.R.M algorithm for decryption (Cryptography)
This file gets the encrypted file and decrypts it. For decrypting process it does the
following functions
page 29
They are
1. Gets the encrypted file as the input
2. Gets the algorithm selection key from the user.
3. Gets the key that was used to encrypt, to decrypt the file.
4. Decrypts according to the character value in the reverse order.
5. Gets the plaintext and writes it into a file.
Functions Explanation:
1. This first takes the encrypted file as the input, by giving the user the option of
selecting the encrypted file.
2. Then the receiver is expected to give out the same algorithm selection key.
3. Then the user will be expected to enter the key that was used to encrypt the
plaintext.
4. Then it takes in each and every character from the last and decrypts one by one
once again forming a logical pipeline from the last and then coming till first
character such that the process of decryption is organized in its manner.
5. Then after decrypting it writes the plaintext recovered back to a file.
Functions of S.R.M algorithm for Embedding (Digital Watermarking)
page 30
Digital watennarking means the user will be embedding some of his details or details
regarding the file like license number, version, author etc. such that it would be
useful for the receiver to check for the right sender. We have used the SRM
algorithm for embedding in watennarking also.
The functions provided by this module is
1. Getting the infonnation from the user.
2. Storing it in an array
3. Using S.R.M algorithm for embedding it embeds the infonnation into the bitmap
image there by acting as a logical header defined by the user.
4. Then we will proceed with embedding of real text.
Functions Explanation:
1. The user will be giving a confidential infonnation which is useful for the receiver
to to check the correct sender which will be usually about the file they are sending
or about the sender
2. Then that infonnation will be stored in an array and then using SRM algorithm for
embedding that its storing the message bit in any bit of the byte of the cover file.
Functions of SRM algorithm for extraction and verification (Digital Watermarking)
page 31
--- - - --
The functions that are provided by the extraction and verification process is
1. First the embedded message will be extracted using S.R.M algorithm of
extraction.
2. Then it will be stored in some array.
3. Then it will be verified with the original description that the sender has sent and
proceed for further process if it is same else it will stop, specifying an error.
Functional Explanations:
The message ITom the logical header created by the sender will be extracted by the
receiver and that message will stored in array. Then the receiver will be having his own
copy of that message and he will check both the values to check whether both are same.
If so it is ITomthe right sender. Else it is not so.
If there is any inconsistency in any of the values then the program will show an error and
will not make the receiver to proceed further.
Functions of SRM algorithm for password autltentication
Password authentication will be in the receiver side to find the legitimacy of the receiver.
This password authentication protocol provides various functions. They are
1. The user should enter the password. If he enters the right password he will be
proceeding further to the next session.
page 32
2. If not then a log file will be generated which stores the exact date and time of this
password typing in that file and also the result of the password typing, whether it
was a successful attempt or not.
Functional Explanations:
The user will be entering the password and the number of attempts will be shown. At
every wrong entry of password, attempts will be reduced. Initially the attempts will
be O.Ifthe no. of attempts reaches 3,there will be a log file, which captures the system
date and system time. Then if the user has entered the password then it stores that the
user has entered the right password. Else it will store about the details during the
password entry that is the date and time in the log file..
System Requirements:
Hardware Requirements:
. A minimum of 300Mhz processor
. A minimum of 64 Mb RAM
. No strict specification about the hard disk.
Software Requirements:
. Windows 9812000/XPplatform
. C++(optional) & JAVA
. Wav file incase of data hiding in audio files, Bitmap/gif files in case of image
files.
. Any file to embed(music, image etc.)
These are the various requirements that are needed. In case of C++ we worked on
Turbo C and incase of JAVA we worked onjdk 1.3.
page 33
-- --
SYSTEM DESIGN
System Architecture:
WaterMarking Encrypt Embed Transfer
Password
success success
decrypt
34
Digital Password-...Watermarking
authentication Receive
verification
Un recognised Exit
sender error message
UnreadableExtraction format to decrypt Original messager
failur wrong decryption
Unreadable Unreadable formatmessage cannot be due to wrong pagedecrypted decryption
Program Modules:
There are totally 9 modules available in this project.
They are
Module 1
Module 2
Module 3
Module 4
Module 5
Module 6
Module 7
Module 8
verification)
Module 9
LSB algorithm
SRM algorithm for steganography (Embedding)
SRM algorithm for steganography (Extracting)
SRM algorithm for cryptography (Encrypting)
SRM algorithm for cryptography (Decrypting)
SRM algorithm for Password authentication
SRM algorithm for digital watermarking (embedding)
SRM algorithm for digital watermarking (extraction and
Interface design
LSB -a programming approach:
This program is done in both C++ and JAVA. Let us see this program in C++ point of
VIew.
We will be getting two files as input. One file is a bitmap image and another is the
message that is going to be embedded using the fopenO function.
Then we have written a function called check( ) which checks the file size of both the
files and determines whether the message can be embedded or not.
Then we have performed a function called embedding function called embed( ) where
the real message file is embedded. Let us see how we have implemented in program.
page 35
. ..- -. ... --
Let the message byte be 11100101
Let the image bytes be 11111011,11111111,11100001,01011010.
We can embed the last 4 bits of the message bit in these 4 bytes. This is done by
Taking the first byte of the image file that is 11111011 and bitwise and it wil OxFE so
that the value will be 11111010.
Then take the message byte and first AND it with Ox01.So that we will get 00000001.
Then OR both the values. We will get 11111011. Well we have embedded the message
bit in LSB of the bitmap image. To embed the next bit we shall take the next bitmap byte
and then AND the message byte with Ox02.Similarly continue taking bits ITommessage
by ANDing it with Ox04,Ox08,Ox10,Ox20,Ox40,Ox80 and use the same procedure and
OR it and embed the message. As soon as we find the file size we should embed the file
size also so that it would be helpful in the receiver side.
Then we write a function called Extract(). What we do here is, we first get the file size
and store in a variable and then we will start to uncover each and every byte of message
and after every recovery of message byte we will decrease the file size value which is in
bytes by I.Then we write it in a file.
Module 2 and 3 SRM algorithm for steganography a programming approach
This is implemented in JAVA. What we actually do here is we developed to different
modules for embedding and extracting.
In the embedding module we do only two things
1. Embedding the file size of the message file to be embedded.
page 36
2. Embedding the message text.
For embedding the file size we use the code in following way....
First we will get the file size by using the function in intxt.available( ). Then we will
store it in the bitmap image.
i=O;
while(i<4){
b=(byte)( (intxtsize&s [i]»»(i*8»;
b=(byte )(b&OxOOOOOOFF);
for(j=O;j<8;j++ ){
ch2=inbmp.readO;
bit=(byte)( (b&arr[j]»> >j);
bit=(byte)(bit&l);
temp=(byte )ch2;
temp=(byte )(temp&l);
if(temp=bit){
outbmp. write«byte )ch2);
} /lend of if
else
if(bit O){
temp=(byte )ch2;
temp=(byte )(temp&OxFE);
outbmp. write(temp);
} /lend of if
else
if(bit 1){
temp=(byte )ch2;
temp=(byte)( templl);
outbmp. write(temp);
page 37
. ._ .. _0. . . _ .. _.. . _._ . --- - -----
} /lend of if
} Ilend of for
i++;
} /lend of while
Then we have implemented the code for embedding the text file and it is being given in
the APPENDIX part ofthis project.
Similarly in order to extract the message that is being embedded we have developed
another module called NewExtractJava
In both embedding and extracting module we have generated the random numbers and
both the numbers generated in different modules were synchronized.
We have to import the following class
Import java.util.Random;
Then we create an object for the Random class by
Random r =new Random(seed);
This generates the same sequence of number for same seed value regardless of the
systems it is used. we generate the next sequence of random number both in embedding
and extracting module by the function
r.nextIntO;
page 38
The same thing in generated in both the modules so, there does not exist any
inconsistency in selecting the exact bit where the message bit is being embedded.
Module 4 and 5.. SRM algorithm for Cryptography a programming approach:-
As already said in the previous pages of this project, we will have 2 keys in this
algorithm. Weare using 10 algorithms here where there are 2 primitive algorithm and 8
derived algorithms. For random number generation we use the same class and the same
function that we used in the previous modules. During the UNIT execution of the
modules we will give the random seed, or key or algorithm selection key in the code it
self. During the INTEGRATED execution the user will have the facility to input the key
in a textbox. In unit execution we give the algorithm selection code and the key in the
following way..
fin=new Fileln pu tStream(" e:\\javaprogs\ \mesg.txt");
out=new FileOu tputStream(" e:\\j avaprogs\\encrypt. txt");
String num,asel;
asel=" 1111";
num=" 123456789012345";
keysize=num.lengthO;
long seed=Long.parseLong(num);
r=new Random(seed);
filesize=fin.avaiiableO;
arr=new byte(filesize];
ch=fin.readO;
i=O;
page 39
while(ch!=-l){
arr[i]=(byte)ch;
ch=fin.readO;
i++;
} /lend of while
The use can input the algorithm selection key which can be of any size. The detailed
explanation of all the algorithms and also the detailed codes are given in the algorithm
and appendix sections respectively.
Module 6.. ..SRM algorithm for Password Authentication a programming approach
This is implemented in JAVA. The user will be typing a password in the interface and
that password would be validated. If the password is correct then he will be proceeding
towards the next session of verification that is the digital watermarking. Else he will be
expected to type the password again.3 such attempts will be given to the user. If the user
does not enter the correct password then what happens is the program will be exited and
then a log file will be created which stores all the details regarding the password entry
that is the exact date and time of entry and then stores in the log file such that the
administrator will be knowing about that and incase of any misuse he will be alarmed and
he can take necessary steps to avoid that. We have even found a new version for that
password generation which is put in further enhancements.
String sndmame="";
this.attempt=3;
do{
try {
sndmame=JOptionPane.showInputDialog(this,"Enter the sender's
name( exactly 6 chars):","For Authentication
:attempts="+this.attempt,JOptionPane.OK_OPTION);
page 40
if(sndmame.lengthO! =6) {
JOptionPane.showMessageDialog(this,"name should be 6
chars");
sndmame="";
} Ilendofif
}catch(Exception e) {sndmame="";}
} while(sndmame.equals('''')); Ilend of do-while
nx=new NewExtract(this.ipbmp,this.exfile,rkey2,sndmame);
JOptionPane.showMessageDialog(this,nx.result);
this.attempt--;
if(!nx.result.endsWith("ver!")){
aseI2=this.extasel.getTextO;
this.jf.showSaveDialog(this);
String outfile=jf.getSelectedFileO.getPathO;
dec=new Decrypt(this.exfile,outfile,aseI2,rkey2);
JOptionPane.showMessageDialog(this,dec.result);
} II end of error check
The details are stored in logfile.
Module 7 and 8... Digital Watermarking a programming approach:-
We implemented the concept of Digital watermarking in both LSB and SRM algorithm
but in overall integration we have used the SRM algorithm, but for simply the digital
watermarking concept we used LSB algorithm for Digital watermarking. Watermarking
using LSB is developed in C++ and SRM algorithm for Digital watermarking is done in
Java. For simple explanation regarding this module we shall see the C++ code and the
Java code is attached in APPENDIX part of this project.
page 41
-- - --
void mainO
{
frombmp=new unsigned char[strlen(desc)];
clrscrO;
int q=O;
q=strlen( desc);
fulldetails=new unsigned char[ q];
watermark wm; II object initialised
// the following code checks which attribute of the file is bigger
cout«"tranformation is on the progress, please wait"«endl;
delay(3000);
wm.transformO;
cout«"Water marking is on the progress, please wait"«endl;
delay(3000);
wm.watermarO;// watermarking is done in this function
cout«"now u r going to enter the extraction function "«endl;
wm.extractO;//extraction is done
for(i=O;i<loop;i++)
{
if(targ[i]=frombmp[i]) //checking the values for verification
continue;
else
cout«"not verified"«endl;
exit(l );
}
cout«" verified "«endl;
delay(2000);
}
page 42
First the embedding information is stored in an array and then it is embedded in a bitmap
image. At the receiver side the user will extract the message and he will again store the
value in an array and both the arrays are checked to hold the same values and then the
corresponding verification message is shown.
INTERFACE:
Our Interface will have 3 panes. The first pane can be selected to use only LSB
algorithm. The second pane can be used for SRM algorithm and the third pane is to know
about the credits. SRM algorithm can also be used with encryption or without encryption.
If it is without encryption, then the textboxes to get the input regarding the encryption
will be disabled and no data can be entered. A textbox is provided to enter the key 2
embed, extract, algo selection key, encryption key. The same interface is provided for
both sender and receiver and both the facility to embed and extract is provided within that
interface.
package New;
import New.*;
import java.lang.*;
import java.awt. *;
import j ava.awt.event.*;
import javax.swing. *;
import javax.swing.filechooser. *;
class IntforSteg extends JPanel{
static JIntemalFrame frame;
JTabbedPane pane;
JButton ipfile,opbmp,EmbedBut,ExtractBut;
JLabel cfl ,cf2,key,status;
JTextField keytxt;
String infilename='''' ,inbmpname='''',outbmpname="";
page 43
long inkey=O;
public IntforStegO{ //constructor
setLayout(new BorderLayout(5,5));
JLabel mainlab=new JLabel("WELCOME
STEGANOGRAPHER",JLabel.CENTER);
pane=new JTabbedPaneO;
pane.setSize(500,700);
pane.addTab("Embedding",new EmbedO);
pane.addTab("Extracting",new ExtractO);
add(mainlab,BorderLayout.NORTH);
add(pane,BorderLayout.CENTER);
TO S.R.M
} //Constructor Ends
class ExtractListener implements ActionListener{
public void actionPerformed(ActionEvent ae){
if(ae.getActionCommandO.equals("extract")){ //perform Embedding here
} //If ends
ALGORITHMS:
LSB algorithm:
Embedding in sender side
1. Start
2. Open two files, a bitmap file (source) and a message file.
3. find the text file size and embed it after 54 bytes.
page 44
4. Open a separate bitmap file (destination).
5. Take the first 54 bytes from the source bitmap image and write directly to the
destination bitmap image.
6. Then embed the file size into it.
7. Take a byte from the bitmap image, and take a bit from the message byte and
embed it into the least significant bit of the bitmap image.
8. Continue this till end of file for the message file.
9. Then write all the remaining bytes of bitmap image(source) directly to the
destination bitmap image.
10. Stop
Extraction in the receiver side
1. Start
2. Open the file which holds the embedded message(source).
3. Open a text file(incase of message text embedded).
4. Skip the first 54 bytes in the bitmap image as it holds only the header information
5. Then get the file size by uncovering the bits embedded in the LSB.
6. While file size not equal to 0 do
7. Uncover each and every bit of message from the LSB of the bitmap image and for
every 8 bytes of bitmap image 1 byte of message will be stored. So at every
retrieval of 1 byte of message write the byte in a text file.
8. Decrease the file size.
9. Loop this action
10. When file size reaches 0, quit the program
11. stop
Algorithm for SRM algorithm for steganography
page 4S
-- --
Embedding in the sender side
1. Start
2. Open two files a bitmap file (source) and a message file (text).
3. The message should contain text.
4. Find the message file size.
5. Skip the first 54 bytes of the bitmap
6. Open a target bitmap file
7. Write the 54 bytes directly into it.
8. Then embed the file size of the message file.
9. Initialize a random number generator and give a seed value say x.
10. A sequence of random numbers will be generated with value < x.
11. Take that value and mod it with 8.
12. The mod value is the bit position selected to embed the message bits.
13. If the mod value is 0, then normal LSB is used.
14. If the mod value is non zero then it should be embedded in any of the bits from
Ito 7.
15. There are two cases in embedding message in non LSB
Case1: If the bit in the position selected and the message bit that should be
embedded are same then
(a) turn the value ofLSB to 0
(b) Don't make any changes in the selected position, assume that the bit is
embedded as the values are same.
Case2: If the bit in the positions elected and the message bit are unequal then
(a) Change the value of the LSB to 1, indicating that the message bit value is
NOT of the current bit value of that position.
(b) Don't make any change in the bit of that position, assume that NOT of that
bit value is stored as LSB is used as a flag.
page 46
16. Proceed this action until the end of file for the text file is detected.
17. When end of file is detected, stop the process.
Extraction in the receiver side
1. Get the bitmap file where the message is embedded (source).
2. Open a text file to write the message that would be extracted.
3. Skip the first 54 bytes in the bitmap image.
4. Extract the file size that is embedded after the header information.
5. Store it in a variable.
6. Until the file size reaches 0, do the following
7. Generate the same random number series with the same seed value that is used
during the embedding process.
8. The same sequence of value will be generated.
9. Mod the value with 8.
10. Check the reminder
11. If the reminder is 0, then the message bit is in LSB, uncover it.
12. Then again check the number in the next sequence.
13. Mod it again with 8.
14. If the reminder is non 0, then check the LSB.
15. If LSB is 0, then the bit in non zero position is taken and shifted accordingly to
augment it to form a byte.
16. If LSB is not 0, then the NOT of bit in non-zeroth position is taken and attached
accordingly to find the message bit.
17. It is done up to 8 bytes to find the exact message byte and then it is written in the
text file.
18. Decrease the value of the file size.
page 47
19. Loop these actions.
20. When end of file is reached the program quits
21. Stop.
SRM algorithm for Cryptography
Encryption at the sender side:
1. Start
2. Get the file to be encrypted.
3. Enter the algoritlun selection key.
4. Enter the Encryption key.
5. Each and every digit of the algoritlun selection key is extracted and that
corresponding algoritlun is chosen.
6. The encrypted file is fed as the input for the algoritlun represented by the next
digit.
7. This is done until the last number in the key is found.
8. The encrypted file is then sent.
9. Stop
Decryption at the receiver side:
1. Start
2. Get the encrypted file to decrypt.
3. Enter the same algoritlun selection key
4. Enter the same encryption key.
page 48
5. Each and every digit of the algorithm selection key is chosen in the reverse order
and decrypted according to the algorithm represented by the digit.
6. The decrypted file is fed as an input to the next algorithm represented by the next
preceding digit for decryption.
7. This is done until the first digit is reached.
8. Check if the file is decrypted.
9. Stop
Now let us see the algorithm of the 10 encryption/decryption algorithm used:
ENCRYPTION ALGORITHM
Main Algorithm:
1.Get the algorithm selection key(asel) and the Random number generation
initializing key(Seed).
2.0pen the file which has to be encrypted and store its contents in a byte array(arr[]).
3.Take a character from the asel key and perform the corresponding algorithm on the
byte array (arr[]).
EX: If the character is '9' perform the 10th algorithm.
If the character is '5' perform the 6th algorithm.
etc
First Algorithm is the default algorithm.
4.Continue with step 3 untill the last character of the asel key gets processed.
(NOTE:In step 3 Operating on the same array provides pipelining i.e output of one
algorithm is given as
page 49
input to the next algorithm.)
Sub Algorithms:
ALGORITHM -1:
I.Increment the seed once.
2.Initialize the Random number generator with the seed.
3.start a loop (i= 0 to filesize-l)
a. Get a Random number (ran) of range 0-7.
b.Get a byte from the byte array(arr[]).
c.Invert the (ran) 'th bit ,(ran+2)'th bit and (ran+4)'th bit of the byte.
4.End loop(i).
ALGORITHM-1 ENDS
ALGORITHM-2
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.Get a random number(loop) which determines the number for times the following
loop has to executed.(range 0-7)
4.Start a loop (j=0 to loop)
4.a. start a loop (i= 0 to filesize-l)
1. Get a Random number (ran) of range 0-7.
page 50
2.Get a byte from the byte array(arr[]).
3.Invert the (ran) 'th bit ,(ran+2)'th bit and (ran+4)'th bit of the byte.
4.b End loop(i).
5.End loop(j)
ALGORITHM-2 ENDS
ALGORITHM-3
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.Get a random number(iteration) which determines the number for times the
following loop has to executed.(range 0-19)
4.Start a loop (j=0 to iteration)
4.a. start a loop (i= 0 to filesize-l)
1. Get a Random number (ran) of range 0-7.
2.Get a byte from the byte array(arr[]).
3.Invert the (ran) 'th bit.
4.b End loop(i).
5.End loop(j)
ALGORITHM-3 ENDS
ALGORITHM-4
I.Increment the seed once.
page 51
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-I)
a. Get a Random number (ran) ofrange 0-7.
b.Get a byte from the byte array(arr[]).
c.Invert the (ran) 'th bit.
4.End loop(i).
ALGORITHM-4 ENDS
ALGORITHM-5
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.Get a random number(iteration) which determines the number for times the
following loop has to executed.(range 0-19)
4.Start a loop (j=0 to iteration)
4.a. start a loop (i= 0 to filesize-l)
1. Get a Random number (bitno) of range 0-7 which determines the number of
bits to be inverted.
2.Start a loop(k=Oto bitno)
a.Get a Random number(ran) (range 0-7).
b.Get a byte from the byte array(arr[]).
c.Invert the (ran) 'th bit.
3.End loop (k).
4.b End Ioop(i).
page 52
5.End loop(j)
ALGORITHM-5 ENDS
ALGORITHM-6
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-I)
a. Get a Random number (ran) of range 0-7.
b.Get a byte from the byte array(arr[]).
c.If ran is 0 or I then invert the MSB of the byte.
d.If ran is 2 or 3 then invert the LSB of the byte.
e.If ran is 4,5,6 or 7 then
l.Get the contents of the 6th and 5th bits.
2.Combine their values and store the in a variable(a).
Ex: If 6th=0 and 5th=I then=1.
If 6th=I and 5th=I then=3...etc.
3.Select the bit which is 'a+I' no of positions away from 5th bit in a cyclicmanner such that
it stays with in the inner 6bits range (i.e excluding MSB and the LSB).
4.Invert the selected bit.
4.End loop(i).
ALGORITHM-6 ENDS
ALGORITHM-7
I.Increment the seed once.
page 53
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-l)
a. Get a Random number (ran) ofrange 0-7.
b.Get a byte from the byte array(arr[]).
c.If ran is 0 or 1 then invert the MSB of the byte.
d.If ran is 2 or 3 then invert the LSB of the byte.
e.Ifran is 4,5,6 or 7 then
l.Get the contents ofthe 5th and 4th bits.
2.Combine their values and store the in a variable(a).
Ex: If 5th=0 and 4th=1 then=l.
If5th=1 and 4th=1 then=3...etc.
3.Select the bit which is 'a+l' no of positions away from 4th bit in a cyclic
manner such that
it stays with in the inner 6bits range (i.e excluding MSB and the LSB).
4.Invert the selected bit.
4.End loop(i).
ALGORITHM-7 ENDS
ALGORITHM-8
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-l)
a. Get a Random number (ran) of range 0-7.
b.Get a byte from the byte array(arr[D.
c.Ifran is 0 or 1 then invert the MSB of the byte.
page 54
d.Ifran is 2 or 3 then invert the LSB of the byte.
e.Ifran is 4,5,6 or 7 then
l.Get the contents of the 4th and 3rd bits.
2.Combine their values and store the in a variable(a).
Ex: If 4th=0 and 3rd=1 then=1.
If 4th=1 and 3rd=1 then=3...etc.
3.Select the bit which is 'a+I' no of positions away from 3rd bit in a cyclic
manner such that
it stays with in the inner 6bits range (i.e excluding MSB and the LSB).
4.Invert the selected bit.
4.End loop(i).
ALGORITHM-8 ENDS
ALGORITHM-9
I.Increment the seed once.
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-l)
a. Get a Random number (ran) of range 0-7.
b.Get a byte from the byte array(arr[]).
c.If ran is 0 or 1 then invert the MSB of the byte.
d.If ran is 2 or 3 then invert the LSB of the byte.
e.If ran is 4,5,6 or 7 then
l.Get the contents of the 3rd and 2nd bits.
2.Combine their values and store the in a variable(a).
Ex: If3rd=0 and 2nd=1 then=1.
If 3rd=1 and 2nd=1 then=3...etc.
page 55
--- -
3.Select the bit which is 'a+ I' no of positions away from 2nd bit in a cyclic
manner such that
it stays with in the inner 6bits range (i.e excluding MSB and the LSB).
4.Invert the selected bit.
4.End loop(i).
ALGORITHM-9 ENDS
ALGORITHM-l 0
1.Increment the seed once.
2. Initialize the Random number generator with seed.
3.start a loop (i= 0 to filesize-1)
a. Get a Random number (ran) of range 0-7.
b.Get a byte from the byte array(arr[D.
c.Ifran is 0 or 1 then invert the MSB of the byte.
d.If ran is 2 or 3 then invert the LSB of the byte.
e.Ifran is 4,5,6 or 7 then
l.Get the contents of the 2nd and 1stbits.
2.Combine their values and store the in a variable(a).
Ex: If2nd=0 and 1st=1 then=1.
If2nd=1 and 1st=1 then=3...etc.
3.Se1ectthe bit which is 'a+l' no of positions away from 1st bit in a cyclic
manner such that
it stays with in the inner 6bits range (i.e excluding MSB and the LSB).
4.Invert the selected bit.
4.End loop(i).
ALGORITHM-IO ENDS
page 56
----
ENCRYPTIONALGORITHM ENDS
DECRYPTION ALGORITHM
Main Algorithm:
Same as Encryption algorithm Except that
I.asel key has to be reversed
2.asel key's length has to be added to the seed.
before starting the algorithm.
Sub Algorithms (1-10):
Same as the Encryption algorithms Except that
I.The first step of the algorithm should be decrementing the seed(not
Incrementing as in Encrypting)
DECRYPTION ALGORITHM ENDS
NOTE:
Incrementing and decrementing of the seed is done because
if the asel key has repeated characters it might negate the effect of an algorithm
Sometimes this may result in unencrypted input file even after the encryption process
ISover.
page 57
PASSWORD AUTHENTICATION ALGORITHM
1. Start
2. Store the original password in an array
3. Prompt the user to type a password.
4. Keep the initial attempt as 3.
5. If user types the password, check ifit is the correct password.
6. If the password is correct, proceed to the next session.
7. If not, until the attempts become 0 request the user to type the
password.
8. If attempts become 0, then
9. Create and open a log file.
10. Capture the system date and system time
11. Write it in the log file and also the wrong password.
12. Quit from the program
13. Stop
SRM ALGORITHM FOR DIGITAL WATERMARKING
In this the same SRM algorithm for steganography is used. Apart from that, the
following is used.
Watermarking at sender side:
1. Start
page 58
--
2. Embed the infonnation(sender's name in this case) into the bitmap image after
skipping the 54 bytes(header infonnation).
3. Embed the encrypted message.
4. Send to the receiver
5. Stop
Watermarking verification in the receiver side:
1. The receiver will be prompted to enter the sender's name
2. The sender's name from the bitmap will be stored in an array and the name that is
typed by the receiver will also be checked along with that.
3. If they are same then we will further go to the task of extracting.
4. If not then an error message will occur specifying the input of wrong sender
name.
5. Stop.
SYSTEM TESTING:
Both UNIT and INTEGRATED testing are donefor this project.
page 59
Let us see the sample data for LSB algorithm
Two inputs are given. One is the Bitmap image source.bmp and a message file
sundar.txt.
Then they are embedded and put in a separate bitmap image called Desti.bmp and
the extracted file name is Targfile.txt.
Embedding:
Source.Bmp
Sundar.txt
page 60
r::~""""'.'-=>I.'''.'''tI'Ii
~.1'"onn8t t18Iph1d. 5und.,.?Ihow ,. u?
Extracting:
Desti.Bmp
page 61
Targfile.txt
,.,.,"" ".m..., ,.,...
E«PorM8t....h1 d~ sundar?'.IhOW,. u?'
SRM algorithm for Steganography:
Embedding:
Inputs: srm.bmp, text.txt
page 62
Text.txt
.=.JjtQ,;--';"n:..nrr-_' IV~~Xot6~' 'I'"'' PM
Extraction:
Inputfile: Des.bmp
Outputfile: Targfile.txt
page 63
Targfile.txt
SRM ALGORITHM FOR CRYPTOGRAPHY
Encryption:
Inputfile:
Output file:
Text.txt
Text.txt
En crypted.txt
page 64
En crypted.txt
Decryption:
Inputfile: Encrypted.txt
Output file: Decrypted.txt
Encrypted.txt
- .. ~J~.eo-.dgy...llc2~~ .~:.{i.'fCS'6-"'1..~':53PM-
page 65
decrypted. txt
'IJ1:1eo III!1_d...1 ~ ~...I ,--,,-
SRM ALGORITHM FOR PASSWORD AUTHENTICATION
Here, we have given the output of the Logfile that will be generated as result of
invalid password.
Now we have the snapshot of the logfile. . .
page 66
'
1
2004
.
2 220042 220042 220042 200422004 22004 22
U 51524U 515951U 521 65U 523 19U 523 19U 523 1911 533074
Jl€isteg~ay...II~U]f,fJLf.TX..~~4XO~~ 12:04~
SRM ALGORITHM FOR DIGITAL MARKING
There is no big difference between the message embedded and message watermarked
image during a view. Both look same.
page 67
]ltputFile: Source.bmp
Outputfile: Desti.Bmp
Source.bmp
desti.bmp
page 68
SNAPSHOT OF OUR INTERFACE
The interface can be customized in two ways.
1. With Encryption
2. Without Encryption.
With Encryption
~.sRM StcS"'S""pkw I!I!!!~
WELCOMETO S.lt M 5TEGANOGRAPHER
~,~~-~,
.EII".: ~.'. . '" ~-~:-:-' =
=
Elll:lwtberorelHllbeddinG1 .~.Yes:Q'!!o Clnidfle:
r'--~~~~'f IlL:
~I'~~~~':.l IlL:
r~~~~~~~1 IlL:
EnlerRinlomnoi1iLkey: r~::~""~"u
Enter AIgoritIm Selection key:
[~~~:-'_.,.. -,-
[~.~~,.lf'
-~
--- - -.--. -- - - -~ beforeExtractiIg., CIned file:
~1!t "', .~. ,-,"_.~
~!!i"MP File:. -- .'
NIL:
Saw Extracted fie as :_.-~_ _'=-'"c~" .,,,
NIl:
Enter Random no./M. key:
Enter AIgoritIm se/edion key:
r~-'_ "-- --_ .~:_~. __0.
j ~.~.11'... ~ ~ ,. .
-~._,.--~-_. . --,'-'~.'-~-~.-.". .
page 69
Without Encryption
&SAMStcgmgNphlr "1iJ E1
welCOME TO S.R.M STEGANOGRAPHER
:::
Cwenfie:
.. it.:~;~ NL:
I~~~~:~l Nl:
~~tA1!~file~~:J Hi.
Emrp.mnm.iU~:[==~_._"__
~rAl!IoIiIIm~mTref''"
J
o,~J~i'}~1OO . L.___
Cwertfie:
Save Exlractedfile as:' ., - .,-".<"
EnterRMdooIno.ill. key: L
SIltExlract",. I1g
-.-.
page 70
SAMPLE OUPUTS WHEN WRONG PASSWORD IS GIVEN
WELCOMETO S.R.M STEGANOGRAPHER
~.....-
.",.~,.-~~' ~
,ElaNd
Ero)!tbef(feenieckilg? ,~;yes@ ~ CIIJertfie:
t~~ E:~~'~
r~~i~: .~ E:~.1r_
--= =
11'.
,. ._. «-'
MeI!1 Ej,
"I1
CWeitfie:
r. ~.~-~~,;~"p l ~_.~_ """-,,.. . .ftOi' '_. _~~ ~ " ..,.
SawEJdrWdlieas:'1 ~.~
ErterRinbnno.it key. E&:.:t"
I ".
i... "11I ",,'
~~ExIr~....
r.;'.I
..
page 71
SNAP SHOT OF ERROR DURING WATERMARKING VERIFICATION
~.ifIMSt1fMi"U' 8!!1EJ.tft, itIIm fo,sleaanojll~
WELCOME TO S. R. M STEGANOGRAPHER
m~ilmstiWt.--' .. --=
fe..1d '.. -~ ~I ~ beforeernbedIIirG? OYes liNo Cllrertfie:J "- . -
- --- --.-
L. -~ur:~~:.J E:1avaJIogs,ajbat
~.~.~ E;Javaprogs~~-,,!;
filM~r.ttr -'8"
L.
~~. ~ lIeader~orYouare,*1heRendedreceMrl
- . "'-"' ~. -
Melgc ~.
DeaypC before Extracting? 0Y!SCllrertIii!:
t.
CI
lSa\Ie Extracted fie as:
EnterRandomno.ill. key. E'
Emf1l' ,)O',trlTt~iIDr. '011'v ~~~ ~~~~~~~
Start Extracting
page 72
Test Case Design
CONCLUSION:
Advantages:
SRM algorithm for steganography:
. Usage of Random number generators.
. Usage of more than one bit from each byte of every bitmap pixel.
. More resistive towards cracking.
SRM algorithm for cryptography:
page 73
Modules Unit Testing After Integration
1. LSB algorithm Success Success
2.SRM steganography Success Success
3.SRM Cryptography Success Success
4.SRM password Success Success
authentication
5.SRM Digital Success Success
Watermarking
6.Interface Success Success
· Usage of 10 algorithms that are inter dependent.
· Usage of pipelining among the procedures based on sequence.
· Ability to encrypt message as well as any other files
SRM password authentication:
· Not allowing user to enter password more than thrice(if he enters wrong
password)
· Creation of logfile and its utility.
SRM Digital Watermarking:
· Verification of sender at the receiver side
· Abrupt ending of program when there is a mismatch in the sender's name on the
receiver side
FUTURE ENHANCEMENTS:
There can be an enhancement in the future on two things
(1) Password Authentication
(2) Another algorithm in steganography that uses the concept of rule based systems.
(1) The algorithm for password authentication (enhanced) is found and also developed. It
is developed in C++. Further reading is going on regarding its impact in the project and
page 74
--
other things. In this new authentication algorithm, when a user enters the password
wrongly 3 times, then taking the original password as input, it would generate a new key.
After generating the key the password entering session will be closed and the user will be
expected to enter the key. That key is generated through a number of mathematical
functions. That key should be known only to administrator. If the key is typed wrongly
then the previously generated key is taken as the input and a new key is generated again.
The log file in this program along with date and time also stores whether a password
entered was successful and also whether a key was successful, if not how much time it
was attempted to hack etc.
The main advantage of this new algorithm is its resistance against Brute force attacks.
(2)In the new idea of using rule based systems in steganography, we will have a file
specifying a set of rules to embed. That is range of bits to be embedded is based on
the value of pixel. The system should dynamically find the pixel value and
accordingly it should embed the bits based on the rules written in the file. This is on
the process of implementation in Java.
ApplicatiOllS:
. Steganography is used in Defense.
. Used to hide biometric data.
. Watermarking is useful for verification
REFERENCE:
Books:
1. Computer and Communication networks by GACIA.
page 75
- - - -
2. Internet Cryptography by Richard. E. Smith.
3. Introduction to modem cryptography, lecture notes by Mihir Bellare and Phil
Rogaway
4. William Stallings, Cryptography and Network Security: Principles and Practice
5. Bruce Schneier, Applied Cryptography, John Wiley & Sons.
6. Distributed Operating Systems by Pradeep K Sinha
Websites:
1. www.iitc.com
2. www.steganos.com
3. www.wired.com
4. linuxOl.gwdg .del "'alatham/stego. html
5. www.sDammimic.com
6. www.stegoarchive.com
7. www.ourauess.org
8. WWW.cs.uct.ac.za
9. www.cI.cam.ac.uk
10. www.cs.acu.ac.il
APPENDIX:
Sample Code:
LSB algorithm in C++ embedding and extracting
void embedO
{
lIembedding the text in bitmap
page 76
while(!feof(ft))
{
if(c==O)
{
ch=getc(fb);
x=getc(ft);
temp1=ch&Oxfe;
temp2=x&OxO 1;
temp2=tempIltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox02;
temp2=temp2» 1;
temp2=tempIltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox04;
temp2=temp2»2;
temp2=tempIltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox08;
temp2=temp2» 3;
temp2=tempIltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox 10;
page 77
---
temp2=temp2>>4;
temp2=temp Iltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox20;
temp2=temp2»5 ;
temp2=temp Iltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox40;
temp2=temp2»6;
temp2=temp Iltemp2;
fputc(temp2,fd);
ch=fgetc(fb);
temp1=ch&Oxfe;
temp2=x&Ox80;
temp2=temp2»7;
temp2=tempIltemp2;
fputc(temp2,fd);
c=l;
}
if(c=l)
{
f=f+1;
cout«"itemation #"«f;
c=O;
embedO;
}
page 78
}
while«!feof(fb »&&(feof(ft»)
bitmap
II embedding the rest of the details ofsource
{
ch=fgetc(fb);
fputc(ch,fd);
}
}
II image to the destination bitmap image *1
void extractO /*function to extract the text embedded in desti.bmp
to a new target file targfile.txt *1
{
x=O;
fd=fopen("desti.bmp","rb+");
if(!fd)
{
cout«"no destination file"«endl;
cout«"first embed the contents in a file and then go for extraction"«endl;
delay(3000);
exit( I);
}
tf=fopen("targfile.txt","a+");
delay(2000);
for(int m=O;m<54;m++)
{
cout<<"tfsize is"<<tfsize<<endl;
header[m]=fgetc(fd);
}
cout«"header separated"«endl;
while(tfsize!=O)
page 79
{
chl=fgetc(fd);
temp 1=ch 1&OxO 1;
chI =fgetc(fd);
chl=chl&OxOl;
chl=chl «1;
temp 1=temp llch 1;
chI =fgetc(fd);
chl=chl&OxOI;
chl=chl«2;
tempI=tempIlchI;
chI =fgetc(fd);
chl=chl&OxOI;
chl=chl «3;
temp 1=temp llch 1;
chl=fgetc(fd);
chl=chl&OxOl;
chl=chl «4;
temp I=temp Ilch 1;
ch 1=fgetc( fd);
ch 1=ch I &OxO 1 ;
chl=chl«5;
temp I=temp Ilch 1;
chI =fgetc(fd);
chl=chl&OxOl;
chl=chl«6;
temp 1=temp Ilch 1;
chl=fgetc(fd);
chl=chl&OxOI;
chl=chl«7;
temp 1=temp Ilch 1;
page 80
fputc( temp 1,tf);
tfsize-= 1;
}
cout«endl;
cout«"extraction completed"«endl;
}
SRM algorithm for steganography in JA VA
system. out. println("Please wait... It);
try {
intxt=new FileInputStream("e:\\javaprogs\\mesg.txt");
inbmp=new FileInputStream("e:\\javaprogs\\tree.bmp");
outbmp=new FileOutputStream("e:\\javaprogs\\dest.bmp");
intxtsize=intxt.availableO;
outbmpsize=inbmp.availableO;
if«outbmpsize-54-32)/8 <= intxtsize){
System.out.println("cannot embed..");
System.exit(O);
} Ilend of if
intj;
int chl,ch2;
for(j=O;j<54;j++){ lithe header is written as such in to the output file
ch2=inbmp.readO;
outbmp.write((byte)ch2);
} Ilend of for
byte b;
byte bit,temp;
Iistoring the size of the text file
page 81
i=O;
while(i<4) {
b=(byte)((intxtsize&s(i]»»(i *8));
b=(byte )(b&OxOOOOOOFF);
for(j=O;j<8;j++) {
ch2=inbmp.readO;
bit=(byte )((b&arr[j]»»j);
bit=(byte )(bit& 1);
temp=(byte )ch2;
temp=(byte)( temp& 1);
if(temp bit){
outbmp.write( (byte )ch2);
} Ilend of if
else
if(bit=O) {
temp=(byte)ch2;
temp=(byte)(temp&OxFE);
outbmp.write(temp);
} Ilend of if
else
if(bit=l){
temp=(byte)ch2;
temp=(byte)(templl);
outbmp.write(temp);
} IIend of if
} Ilend of for
i++",
} IIend of while
page 82
II storing the text file in to bmp
long seed;
String num="1234567890";
seed=Long.parseLong(num};
Random r=new Random(seed};
int mo=O;
int and= 1,shifter=O;
ch 1=intxt.readO;
while(chl !=-1){
b=(byte }ch1;
for(j=0;j<8;j++} {
ch2=inbmp.readO;
bit=(byte}( (b&arr[j]»»j);
bit=(byte }(bit& I);
mo=r.nextIntO;
if(mo<O}mo=mo*( -I};
mo=mo%5;
switch(mo}{
case 0:
and=1;
shifter=O;
break;
case 1:
and=Ox80;
shifter=7;
break;
case 2:
and=Ox40;
shifter=6;
page 83
- -
temp=(byte)ch2;
temp=(byte)(temp&and);
temp=(byte)(temp»>shifter);
temp=(byte)(temp&1);
if(temp=bit) {
if(shifteI--O) {
outbmp.write((byte)ch2);
} Ilend of if
else{
outbmp. write( (byte)( ch2&OxFE));
} I/END OF ELSE
} Ilend of outer if
else{
if(shifter==O){
if(bit=O) {outbmp.write((byte)(ch2&OxFE));}
else
if(bit=l) {outbmp.write((byte)( ch211));}
} Ilend of if
page 84
break;
case 3:
and=Ox20;
shifter=5;
break;
case 4:
and=Ox 10;
shifter=4;
break;
} Ilend of switch-case
else{
outbmp.write((byte)(ch211»;
} Ilend of else
} IIEND OF ELSE
} Ilend of for
chI=intxt.readO;
} Ilend of while
intxt.closeO;
ch2=inbmp.readO;
while(ch2!=-I){
outbmp.write((byte)ch2);
ch2=inbmp.readO;
} Ilend of while
inbmp.closeO;
outbmp.closeO;
System.out.println("Size of text file= " +intxtsize + "Bytes");
System.out.println("Size ofbmp file= " +outbmpsize + "Bytes");
} Ilend of try
catch(Exception ioe){
System.out.println("Some file Error.."+ioe);
} Ilend of catch
} Ilend ofmainO
} Ilend of Project-class
class NewExtract{
public static void main(String args[Dthrows IOException{
int ij,txtsize;
int s[]=new int[4];
page 85
s[ O]=OxFFFFFFOO;
s[ 1]=OxFFFFOOFF;
s[2]=OxFFOOFFFF;
s[3 ]=OxOOFFFFFF;
FileInputStream inbmp;
OutputStream outtxt;
inbmp=new FileInputStream("e:\\javaprogs\\dest.bmp");
inbmp.skip(54);
i=O;
byte b,bit=O,temp=O;
int chI;
txtsize=OxFFFFFFFF;
int t=O;
IIgetting the size of the text file
while(i<4){
temp=O;
forG=0;j<8;j++){
ch1=inbmp.readO;
b=(byte)(ch1);
bit=(byte)(b&1);
if(bit=O) {
temp=(byte)(temp»> 1);
temp=(byte)(temp&Ox7F);
} //endofif
else
if(bit==1){
temp=(byte)(temp»> 1);
temp=(byte)(tempII28);
} Ilend of if
} Ilend of for
t=temp;
page 86
t=t«(i*8);
t=tls[i];
txtsize=txtsize&t;
i++',
} Ilend of while
outtxt=new FileOutputStream("e:\\javaprogs\\desttxt.txt");
Ilgetting the contents of the text file
i=l;
int a=O,mo=O;
long seed;
String num="12345678901";
seed=Long.parseLong(num);
Random r=new Random(seed);
while(i<=txtsize) {
temp=O;
for(j=0;j<8;j++){
chI =inbmp.readO;
b=(byte )ch 1;
mo=r.nextIntO;
if(mo<O)mo=mo*(-1);
mo=mo%5;
switch(mo){
case 0:
bit=(byte )(b& 1);
break;
case I:
a=(byte)(b&I);
bit=(byte)«b&Ox80»»7);
bit=(byte)(bit&1);
page 87
case 2:
case 3:
case 4:
--
if(a==1){
if(bit=l)bit=O;
else bit=l;
} Ilend of if
break;
a=(byte)(b&1);
bit=(byte)((b&Ox40»»6);
bit=(byte)(bit&1);
if(a=l){
if(bit= 1)bit=O;
else bit=l;
} Ilend of if
break;
a=(byte)(b&l);
bit=(byte)((b&Ox20»»5);
bit=(byte)(bit&1);
if(a=l){
if(bit 1)bit=O;
else bit=l;
} Ilendofif
break;
a=(byte)(b&l);
bit=(byte)((b&Ox10»»4);
bit=(byte)(bit&1);
if(a==l){
page 88
- - -
if(bit= 1)bit=O;
else bit=l;
} Ilendofif
break;
} Ilend of switch-case
if(bit 0) {
temp=(byte)(temp»> 1);
temp=(byte)(temp&Ox7F);
} IIend of if
else
if(bit=l){
temp=(byte)(temp»> 1);
temp=(byte)(tempI128);
} Ilendofif
} Ilend of for
outtxt.write(temp);
i++',
} Ilend of while
outtxt.closeO;
inbmp.closeO;
System.out.println("size of text file= "+txtsize + " bytes");
System.out.println("output file= desttxt.txt is created in root directory");
} Ilend ofmainO
} IIend of Extract class
page 89
SRM algorithm for cryptography ill JA VA
switch( asel.charAt(l» {
case '0': //first algorithm
seedinc++;
r.setSeed( seed+seedinc);
for(i=O;i<filesize;i++) {
ran=r.nextIntO;
if(ran<O)ran*=( -1);
ran%=8;
bit=(byte)« arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]Ibitpos1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
ran=(ran+2)%8;
bit=(byte)« arr[i]»>ran)& 1);
if(bit=O)arr[ i]=(byte)(arr[i]lbitpos1[ran]);
else
arr[ i]=(byte)( arr[i]&bitpos2[ ran]);
ran=(ran+2)%8;
bit=(byte)« arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos1[ran]);
page 90
case '1':
else
an-[i]=(byte)( arr[ i]&bitpos2[ ran]);
} Ilend of for
break;
Iisecond algorithm
seedinc++;
r.setSeed(seed+seedinc);
int loop=r.nextIntO;
if(loop<O)loop*=(-1);
loop%=8;
for(j=O;j<loop;J++)
for(i=O;i<filesize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
ran%=8;
bit=(byte)((arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]Ibitpos1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
ran=(ran+2)%8;
bit=(byte )« arr[ i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos 1[ran]);
else
arr[i]=(byte)( arr[ i]&bitpos2[ ran]);
page 91
- - -
case '2':
ran=(ran+2)%8;
bit=(byte)« arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos1[ranD;
else
arr[i]=(byte)( arr[ i]&bitpos2[ ranD;
} Ilend of for
break;
Iithird algorithm
seedinc++;
r.setSeed(seed+seedinc);
iteration=r.nextIntO;
if(iteration<O)iteration*=(-1);
iteration%=20;
for(j=O;j<iteration;j++)
for(i=O;i<filesize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
ran%=8;
bit=(byte )« arr[i]»>ran)&I);
if(bit=O)arr[ i]=(byte)( arr[i]lbitpos 1[ranD;
else
arr[i]=(byte)( arr[ i]&bitpos2[ ranD;
page 92
case '3':
case '4':
- -
} Ilend of for
break;
Ilfourth algorithm
seedinc++;
r.setSeed(seed+seedinc );
for(i=O;i<filesize;i++) {
ran=r.nextIntO;
if(ran<O)ran*=( -1);
ran%=8;
bit=(byte)«arr[i]»>ran)&l);
if(bit=O)arr[ i]=(byte)(arr[i]lbitpos1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
} Ilend of for
break;
lififth algorithm
seedinc++;
r.setSeed(seed+seedinc);
iteration=r.nextIntO;
if(iteration<O)iteration*=(-1);
iteration%=20;
int bitno;
page 93
forU=O;j<iteration;j++ )
for(i=O;i<filesize;i++) {
bitno=r.nextIntO;
if(bitno<O)bitno*=( -1);
bitno%=8;
for(k=O;k<bitno;k++) {
ran=r.nextIntO;
if(ran<O)ran*=( -1);
ran%=8;
bit=(byte)( (arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos 1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
} Ilend of for(k)
} Ilend of for(i)
break;
Decryptioll:
switch(asel.charAt(1)){
case '0'; lifirst algorithm
r.setSeed(seed+seedinc);
seedinc--;
for(i=O;i<filesize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
ran%=8;
bit=(byte)((arr[i]»>ran) &1);
if(bil O)arr[i]=(byte)(arr[i]lbitpos1[ran]);
else
page 94
case '1':
arr[ i]=(byte)( arr[i]&bitpos2[ ran]);
ran=(ran+2)%8;
bit=(byte )((arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i] Ibitpos1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
ran=(ran+2)%8;
bit=(byte)((arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos1[ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
} Ilend of for
break;
Iisecond algorithm
r.setSeed(seed+seedinc);
seedinc--;
int loop=r.nextIntO;
if(1oop<O)loop*=(-1);
loop%=8;
for(j=O;j<loop;j++)
for(i=O;i<filesize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
page 95
- - - -
case '2';
ran%=8;
bit=(byte )« arr[i]»>ran)& I);
if(bit O)arr[i]=(byte)(arr[i]IbitposI [ran]);
else
arr[ i]=(byte)( arr[i]&bitpos2[ ran]);
ran=(ran+2)%8;
bit=(byte )« arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte)( arr[i]lbitpos I [ran]);
else
arr[i]=(byte)(arr[i]&bitpos2[ran]);
ran=(ran+2)%8;
bit=(byte)« arr[i]»>ran) &I);
if(bit=O)arr[i]=(byte)( arr[i]IbitposI [ran]);
else
arr[i]=(byte)( arr[ i]&bitpos2[ ran]);
} Ilend of for
break;
Iithird algorithm
r.setSeed( seed+seedinc);
page 96
---
seedinc--;
iteration=r.nextIntO;
if(iteration<O)iteration*=(-1);
iteration%=20;
for(j=O;j<iteration;j++)
for(i=O;i<fi1esize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
ran%=8;
bit=(byte)((arr[i]»>ran) &1);
if(bit=O)arr[ i]=(byte)(arr[i]lbitpos1[ranD;
else
arr[i]=(byte)(arr[i]&bitpos2[ranD;
} Ilend of for
break;
case '3': Ilfourth algorithm
r.setSeed(seed+seedinc );
seedinc--;
for(i=O;i<fi1esize;i++){
ran=r.nextIntO;
if(ran<O)ran*=(-1);
ran%=8;
bit=(byte)«arr[i]»>ran)&1);
page 97
if(bit==O)arr[i]=(byte)( arr[i]lbitpos 1[ran]);
else
arr[ i]=(byte)( arr[ i]&bitpos2[ ran]);
} Ilend of for
break;
case '4': lififth algorithm
r.setSeed( seed+seedinc );
seedinc--;
iteration=r.nextIntO;
if(iteration<O)iteration*=(-1);
iteration%=20;
int bitno;
for(j=O;j<iteration;j++)
for(i=O;i<filesize;i++){
bitno=r.nextIntO;
if(bitno<O)bitno*=(-1);
bitno%=8;
for(k=O;k<bitno;k++) {
ran=r.nextIntO;
if(ran<O)ran*=( -1);
ran%=8;
bit=(byte)((arr[i]»>ran)& 1);
if(bit=O)arr[i]=(byte )(arr[i]lbitpos1[ran]);
else
arr[ i]=(byte)( arr[ i]&bitpos2[ ran]);
} Ilend of for(k)
--
page 98
} Ilend of for(i)
break;
SRM password Authenticatio in JA VA:
String sndrname="";
sender's
this.attempt=3;
do{
try {
sndrname=JOptionPane.showInputDialog(this,"Enter the
name( exactly 6 chars):","For Authentication
:attempts="+this.attempt,JOptionPane.OK_OPTION);
if(sndrname.1engthO!=6){
JOptionPane.showMessageDialog(this,"name should be 6
chars");
sndrname="";
} Ilend of if
}catch(Exception e){sndrname="";}
} while(sndrname.equals("")); Ilend of do-while
nx=new NewExtract(this.ipbmp,this.exfile,rkey2,sndrname);
JOptionPane.showMessageDialog(this,nx.result);
this.attempt--;
if(!ox.result.endsWith("ver!")){
aseI2=this.extase1.getTextO;
this.jf.showSaveDialog(this);
String outfile=jf.getSelectedFileO.getPathO;
page 99
dec=new Decrypt(this.exfile,outfile,aseI2,rkey2);
JOptionPane.showMessageDialog(this,dec.result);
} II end of error check if
else{
while(true){
if(this.attempt=O) {
JOptionPane.showMessageDialog(this,"attempts over u cant
extract");
try {
fw=new FileWriter("\\log.txt",true);
fw.write("AUTHENTICATION FAILURE: "+new
DateO+"\n");
fw.closeO;
} Ilend oftry
catch(Exception
e){JOptionPane.showMessageDialog(this,"Error accessing log file..exit to System");}
System.exit(1);
}
else{
the sender's
dot
try {
sndmame=JOptionPane.showInputDialog(this,"Enter
name( exactly 6 chars):","For Authentication
ATTEMPTS="+this.attempt,JOptionPane.OK_OPTION);
if(sndmame.lengthO!=6){
JOptionPane.showMessageDialog(this,"name should
be 6 chars");
sndmame="";
} Ilend of if
pagelOO
}catch(Exception e) {sndmame="";}
} while(sndmame.equals(""»; Ilend of do-while
nx=new NewExtract(this.ipbmp,this.exfile,rkey2,sndmame);
JOptionPane.showMessageDialog(this,nx.result);
if(!nx.result.endsWith("ver!"»break;
this.attempt--;
} Ilend of inner else
} Ilend of while
SRM Digital Watermarking in JA VA:
String sendemame="";
do{
try {
sendemame=JOptionPane.showInputDialog(this,"Enter the
sender's name(exactly 6 chars):","For Authentication..",JOptionPane.OK_OPTION);
if(sendemame.lengthO!=6) {
JOptionPane.showMessageDialog(this,"name should be
6 chars");
sendemame="";
} Ilend of if
}catch(Exception e){sendemame='''';}
} while(sendemame.equals(""»; Ilend of do-while
pagelOl
- -
nm=new
NewEmbed(this.enfiIe,this.inbmp,temp,rkey,sendemame);
JOptiOl1Pane.showMessageDiaIog(this,nm.resuIt);
/* .sampIe
code */
//writing the header information in to the file i.e DIGITAL WATER MARKING
/!header is the string which contains the sender's name
/!headerlength=18
byte hd[]=new byte[18];
hd=header.getBytesO;
System.out.println("hd="+header+"Iength="+header.IengthO+hd);
i=O;
//chl=hd[i];
//i++;
while(i<18) {
chl=hd[i];
i++',
b=(byte )ch 1;
for(j=0;j<8;j++) {
ch2=inbmpcontents[ inbmpptr];
inbmpptr++;
bit=(byte)( (b&arr[j]»»j);
bit=(byte )(bit& 1);
mo=r.nextIntO;
if(mo<O)mo=mo*( -1);
mo=mo%5;
switch(mo) {
case 0:
and=1;
shifter=O;
break;
-- -
page102
temp=(byte)ch2;
temp=(byte)(temp&and);
temp=(byte)(temp» >shifter);
temp=(byte)(temp&1);
if(temp=bit){
if(shifter==O){
outbmpcontents[outbmpptr]=((byte)ch2);
outbmpptr++;
}
else{
Ilend of if
outbmpcontents[ outbmpptr ]=((byte)( ch2&OxFE));
page103
case 1:
and=Ox80;
shifter=7;
break;
case 2:
and=Ox40;
shifter=6;
break;
case 3:
and=Ox20;
shifter=5;
break;
case 4:
and=Ox10;
shifter=4;
break;
} /lend of switch-case
outbmpptr++;
} IIEND OF ELSE
} Ilend of outer if
else{
if(shifter==O){
if(bit=O) {outbmpcontents(outbmpptr]=((byte)(ch2&OxFE»;
outbmpptr++;}
else
if(bit 1){outbmpcontents(outbmpptr]=((byte)(ch211»;
outbmpptr++;}
} IIend of if
else{
outbmpcontents(outbmpptr]=((byte)(ch211»;
outbmpptr++;
} Ilend of else
} I/END OF ELSE
} Ilend of for
} Ilend of while
System.out.println("i="+i);
Illterface code:
*
* Gui.java*
pagel04