Вы находитесь на странице: 1из 213

DATA COMPRESSION AND

CRYPTOGRAPHY

by

Priyanka Maheshwari (0602821036)

Monika Garg (2702810002)

Shweta Gupta (060281076)

Swati Tomar (0602810079)

Submitted to the Department of Computer Science

in partial fulfillment of the requirements

for the degree of

Bachelor of Technology

in

Computer Science

IDEAL Institute Of Technology, U.P. Technical University

May, 2009
TABLE OF CONTENTS Page

DECLARATION ................................................................................................... i
CERTIFICATE ..................................................................................................... ii
ACKNOWLEDGEMENTS .................................................................................. iii
ABSTRACT ........................................................................................................... iv
CHAPTER 1 INTRODUCTION OF PROBLEM …............................................ 1
1.1. Existing System......................................................................................... 2
1.2. Proposed System........................................................................................ 3
CHAPTER 2 CHOICE OF LANGUAGE (vb.net) ................................................. 5
CHAPTER 3 SDLC.............................................................................................. 6
CHAPTER 4 FEASIBILITY STUDY................................................................... 9
4.1. Types of Feasibility Study……………………………………………… 10
CHAPTER 5 SOFTWARE REQUIREMENT SPECIFICATION ……………… 12
5.1. Purpose of SRS............................................................................................. 13
5.2. Scope of SRS................................................................................................. 14
CHAPTER 6 FORMAT FOR SRS …...................................................................... 15
CHAPTER 7 SYSTEM ANALYSIS……………………………………………… 17
7.1 Introduction.................................. .................................................................. 18
7.2 Elements of System Analysis.................................. ....................................... 19
7.3. Techniques Used For Analysis.................................... .................................. 19
7.4. Types Of Observation Methods..................................................................... 20
7.5. Existing System.............................................................................................. 20
7.6 Drawback in the existing system........................................................................ 21
7.7. Proposed System................................................................... ……………... 21
7.8 Advantage of the Proposed System………………………………………... 21
CHAPTER 8 DESCRIPTION OF ALGORITHMS USED……………………… . 22
CHAPTER 9 DATA FLOW DIAGRAM AND DESIGN ……………………….. 52
CHAPTER 10 CODING ………………………………………………………… 55
CHAPTER 11 TESTING …………………………………………………… 203
CHAPTER 12 IMPLEMENTATION AND MAINTENANCE................................ 206
DECLARATION

we hereby declare that this submission is our own work and that, to the best of my
knowledge and belief, it contains no material previously published or written by
another person nor material which to a substantial extent has been accepted for the
award of any other degree or diploma of the university or other institute of higher
learning, except where due acknowledgment has been made in the text.

Signature:

Name: Priyanka Maheshwari (0602821036)

Monika Garg (2702810002)

Shweta Gupta (060281076)

Swati Tomar (0602810079)


Date:
CERTIFICATE

This is to certify that Project Report entitled “DATA COMPRESSION AND


CRYPTOGRAPHY” which is submitted by CHITRANSHU MISHRA ,SEEMA
SHEORAN,SILKY JAIN in partial fulfillment of the requirement for the award of degree B.
Tech. in Department of INFORMATION TECHNOLOGY of U. P. Technical University, is a
record of the candidate own work carried out by him under my supervision. The matter
embodied in this report is original and has not been submitted for the award of any other
degree.

Date: Supervisor

27, April 2009 Ms. Archana Pandey


ACKNOWLEDGEMENT

It gives us a great sense of pleasure to present the report of the B. Tech Project undertaken
during B. Tech. Final Year. We owe special debt of gratitude to Ms. Archana Pandey,
Department of Information Technology, Ideal Institute Of Technology, Ghaziabad for her
constant support and guidance throughout the course of our work. Her sincerity,
thoroughness and perseverance have been a constant source of inspiration for us. It is only
her cognizant efforts that our endeavors have seen light of the day.

We also take the opportunity to acknowledge the contribution of Mr. Naresh Trivedi, Head of
Department of Information Technology, Ideal Institute Of Technology, Ghaziabad for his full
support and assistance during the development of the project.

We also do not like to miss the opportunity to acknowledge the contribution of all faculty
members of the department for their kind assistance and cooperation during the development
of our project. Last but not the least, we acknowledge our friends for their contribution in the
completion of the project.

Signature:

Name : CHITRANSHU MISHRA (0502813018)

SEEMA SHEORAN (0502813044)

SILKY JAIN (0502813051)

Date: 27, April 2009


ABSTRACT
This project is intended to provide the functionality of both the Compression and that of
Cryptography in one single software .In the present scenario for providing Compression and
Cryptography we have to use two different softwares .Compression techniques are used to
reduce the size if the data where as Cryptographic techniques are used to provide the security
to the data by either hiding it or by converting it to a form that cannot be easily understood by
unauthorized persons. Using two different softwares poses many problems for the user. It
takes more amount of time while using the two software also there are many compatibility
issues related to the use of two different software. Various algorithms like Run length
encoding, lzw are used for compressing the data where as DES, AES, and Steganography are
used for implementing Cryptography. The main aim of this project is to construct a single
system that can provide both the data compression and cryptographic utilities .This system
will solve many problems related to the use of the two different softwares like compatibility.
Also this project will be able to cut the cost as only single system has to be purchased instead
of two. It will also reduce the time consumption in encrypting and compressing the data as
only one system is used for both the purpose.

This makes DATA COMPRESSION AND CRYPTOGRAPHY SYSTEM easy to use and implement
INTRODUCTION OF PROBLEM

1.1. EXISTING SYSTEM


Existing system are the different software that provides the compression only and some
provide cryptography only .If some organization wants to send an e-mail that contains secret
data and also to reduce the size of the data then different software are to be used. One for
providing encryption and another for providing compression. This will lead to delay of time
since two different software are to be used. Also if the data type of the different software are
not compatible then it can lead to problems. Use of two different software for providing
security and compression poses different problems for the user. Various issues regarding the
use of the two different software has to be solved like compatibility of the data in the two
software.
DRAWBACKS IN EXISTING SYSTEM

 Two different software are required for the purpose of Compression and
Encryption/Decryption.

 Data type of different software may not be the same (compatibility issue)

 Using two different software requires more time as compared to using one .

 Purchasing two different software increases the budget.

 Also training on two different software has to be provided to the user.

1.2. PROPOSED SYSTEM

Proposed system is a software that provides the functionality of both the Compression and
Cryptography .There are two main modules in this proposed software one provides security to
the data via Encryption /Decryption and other reduces the size if the data by compressing it.
For providing cryptograpic utilities AES, DES, triple DES and seganography is used. For
compression (reducing the size of data ) various algorithms like run length encoding, JPEG
compression, LZW are used. The proposed system will eradicate all the problems related to
the use of two different software as in the existing system. The proposed system is easy to use
and handle .

ADVANTAGES OF THE PROPOSED SYSTEM

 The proposed system will provide the functionality of both the Compression and that of
Cryptography .

 The use of one system for both compression of the data and providing security to it will
be less time consuming as compared to that of the existing system.

 The proposed system removes the compatibility issue that is prevailing when we have to
use two different software

 The use of proposed system will also reduce the budget as only one software has to be
purchased for providing both the security and compression.

 The use of the proposed system will also reduce the training as in the existing system
training on two different software are required .
CHOICE OF LANGUAGE
The project Data Compression and Cryptography works on vb.net. vb.net is the language
developed by the Microsoft. Visual Basic is used for devolping this project because it is one of
the powerful programming system that helps in developing sophisticated, graphical
applications that can be run on Microsoft Window environment

Visual Basic supports event driven programming .A program can be developed in three ways
–in modular programming style or in object-oriented style or in event-driven style .In modular
or procedural programming style emphasis is on the the procedure not on the data .In object-
oriented programming style emphasis is on the objects. Event driven programming style
responds to the to the user events and is driven by the occurrence of the user event.Visual
Basic provides the combination of the event-driven and the object-oriented style .

The features of the Visual basic are given below:

 VB provides event based programming.

 Common Programming Plateform.VB provides common programming plateform


across all MS-Office applications.

 Active X support.

 N-tier architecture .

 Quick error detection /correction.

 Quick development. VB offers many tool that provide a quick and easy way to
develop applications.

 Wizards.VB also provides many wizards that can automate tasks or even automate
coding.
SYSTEM DEVELOPMENT LIFE CYCLE(SDLC) MODEL

This is also known as Classic Life Cycle Model (or) Linear Sequential Model (or) Waterfall
Method. This model has the following activities.

1. System/Information Engineering and Modeling

As software is always of a large system (or business), work begins by establishing the
requirements for all system elements and then allocating some subset of these requirements
to software. This system view is essential when the software must interface with other
elements such as hardware, people and other resources. System is the basic and very critical
requirement for the existence of software in any entity. So if the system is not in place, the
system should be engineered and put in place. In some cases, to extract the maximum
output, the system should be re-engineered and spruced up. Once the ideal system is
engineered or tuned, the development team studies the software requirement for the system.

2. Software Requirement Analysis

This process is also known as feasibility study. In this phase, the development team visits the
customer and studies their system. They investigate the need for possible software automation
in the given system. By the end of the feasibility study, the team furnishes a document that
holds the different specific recommendations for the candidate system. It also includes the
personnel assignments, costs, project schedule, target dates etc.... The requirement gathering
process is intensified and focussed specially on software. To understand the nature of the
program(s) to be built, the system engineer or "Analyst" must understand the information
domain for the software, as well as required function, behavior, performance and interfacing.
The essential purpose of this phase is to find the need and to define the problem that needs to
be solved .

3. System Analysis and Design

In this phase, the software development process, the software's overall structure and its
nuances are defined. In terms of the client/server technology, the number of tiers
needed for the package architecture, the database design, the data structure design etc...
are all defined in this phase. A software development model is thus created. Analysis
and Design are very crucial in the whole development cycle. Any glitch in the design
phase could be very expensive to solve in the later stage of the software
development. Much care is taken during this phase. The logical system of the product
is developed in this phase.
4. Code Generation

The design must be translated into a machine-readable form. The code generation step
performs this task. If the design is performed in a detailed manner, code generation can be
accomplished without much complication. Programming tools like compilers, interpreters,
debuggers etc... are used to generate the code. Different high level programming languages
like C, C++, Pascal, Java are used for coding. With respect to the type of application, the
right programming language is chosen.

5. Testing

Once the code is generated, the software program testing begins. Different testing
methodologies are available to unravel the bugs that were committed during the previous
phases. Different testing tools and methodologies are already available. Some companies build
their own testing tools that are tailor made for their own development operations.

6. Maintenance

The software will definitely undergo change once it is delivered to the customer. There can be
many reasons for this change to occur. Change could happen because of some unexpected
input values into the system. In addition, the changes in the system could directly affect the
software operations. The software should be developed to accommodate changes that could
happen during the post implementation period.
FEASIBILITY STUDY

An initial investigation culminates in a proposal that determines whether an alternative


system if feasible or not. Proposal summarizing the study of the system is presented to the user
for reviews. When approved this proposal initiates feasibility study that meets the system
performance requirement and the objectives.

To test the feasibility of this Online Examination System, following aspects were studied in
details so that there should not be any resistance from the personnel or the user.

The activities studied are:-

• Main characteristics of the system.


• Output requirement including response time.
• Verities of data.
• Feasibility study for user and system manager
• Objective and requirement of system

4.1 TYPES OF FEASIBILITY STUDY

The key consideration involve in feasibility analysis are:-

 Technical feasibility
 Economic feasibility
 Operational feasibility
 Social feasibility

TECHNICAL FEASIBILITY :-
It is determined by evaluating the hardware and supportive software. Hardware requirement
mini computer with 16MB of main memory space. Software requirement visual studio 2005
and window XP for implementation of this system.
ECONOMIC FEASIBILITY:-

Economic analysis is the most frequently used technique for evaluating the effectiveness of a
proposed system. More commonly known as cost-benefit analysis; the procedure is to
determine the benefits and savings that are expected from a proposed system and compare
them with costs. If benefits outweigh costs, a decision is taken to design and implement the
system.

OPERATIONAL FEASIABILITY:-

Proposed system has benefits as it can be turned into information system that will meet the
operating requirement, two main point that followed operational feasibility are:

(1) There is abundant support for the project from user. The new system will linked and used
to extend the person won’t be able to see reasons for a change there may be resistance.

(2) The current methods are acceptance to users. If they are not users, many welcome a change
that will bring about a more operational and useful system.

SOCIAL FEASIBILITY:-

It is the determination of whether a proposed project will be acceptable to the people or not.
This determination typically examines the probability of the project being accepted by the
group directly affected the proposed system change.

Every one wants to invest his money in a reputed insurance company. Such activity and fast
information system improve the social circle of such organization and people as well. Such
projects are always helpful to build an image of the Insurance Company.
SOFTWARE REQIUREMENT SPECIFICATION

SYSTEM REQUIREMENTS

Hardware Requirement:

 System :Pentium 3 or higher


 RAM: 128 MB
 Hard Disk Space: 1 GB

Software Requirement:

 Operating System: Win 9x/NT/2000/XP or any other preferred by the user.


 Microsoft Visual Studio 2005.

5.1 PURPOSE OF SRS:-


The purpose of this document is to:

• Document the different business process of department, in detail.


• Document the business requirement clearly in a concise and easily understood manner
to business/end user.
• Serve as baseline for validation and verification.
• Serve as a baseline document for development team.
• Serve as a basis for future enhancements.

5.2. SCOPE OF SRS:-

The document covers the detailed description of the different process. The details include:

• Description of process.
• Proposed process model.
• Assumptions dependencies and constraints.
FORMAT FOR THE SRS

INTRODUCTION: The introduction of the software requirement specification states the


goals and objectives of the software, describing it in context of the computer based system.

INFORMATION DESCRIPTION: It provides detail description of the problem the software


must solve. Information content, flow and structure are documented. Hardware, software and
human interfaces are described for external system elements and internal software functions.

FUNCTIONAL DESCRIPTION: A processing narrative is provided for each function,


design constraints are stated and justified, performance characteristics are stated, and one or
more diagrams are included to graphically represent to overall structure of the software and
the interplay among software and other system elements.

BEHAVIOURAL DESCRIPTION: This section of the SRS examines the operation of


software as a consequence of external events and internally generated control characteristics

VALIDATION CRITERIA: It is probably the most important and ironically the most often
neglected section of the software requirement specification. This section is neglected because
completing it demands a thorough understanding of the software requirements. Specification
of validation criteria acts as an implicit review of all other requirements, so it is essential that
time and attention is given to this section.

BIBLIOGRAPHY AND REFRENCES: It is also important to put all important references at


the end of documents so that any programmer or user can refer them in
case of any confusion or problems.
SYSTEM ANALYSIS

Before developing any computerized system it is an imperative to examine the existing

system to find out the drawbacks and the system requirements, which will have to satisfy

by the proposed system. It is necessary to examine :

 The current procedure and information flow


 To locate problem in the existing system.
 To identify what resources in the existing system are used.
 To discuss with higher authorities the improvements that is necessary.

7.1. INTRODUCTION

Analysis is the most important phase in he life cycle of a system. While studying or
analyzing and analyst should understand well all aspects of the system should be capable

enough to analyze them if the system is wrongly analyzed then it may lead to an incorrect
design and sub sequently to faulty system. System analyse therefore is the process of studying
the system in details and collecting the necessary information regarding the system to be
designed. System analysis is the management technique that helps us in designing and
improving an existing system.

Following characterstics are present in all systems :

ORGANIZATION : It implies structure and order. It is the arrangement of components that


helps to achieve objectives. For ex. A computer system is desiged around an input device, a
CPU , an Output device and one or more storage units. When these units are linked together,
they work as a whole system for generating information.

INTERACTION : IT refers to a procedure in which each component function with other


components of the system.

In computer system the CPU must interact with other units to solve a problem.

INTERDEPENDENCE : IT means that components of organization of computer system


depend on one another. They are coordinated and linked together in a plannedway to achieve
an objective.
INTEGRATION : It is concerned with how a system is tied together. It is more than sharing
a physical part or locations. Successful integration will typically produce a better result as a
whole rather than if each component works independently.

CENTRAL OBJECTIVE : It is the lat charactrstic of the system. Objective my be real or

stated.

7.2. ELEMENTS OF SYSTEM ANALYSIS

There are four basic elements in system analysis :

Outputs : First of all, we must determine what the objective or goals are, what is the purpose
of our work or what is the main aim behind the system.

Once we know the aim , we can try to achieve it in best possible way. These become the
outputs, which the system analyst keeps into mind.

Inputs : once we know the output, we can easily determine what the input should be. The
essential elements of inputs are :

i. Accuracy
ii. Timeliness
iii. Proper format
iv. Economy

Files: Most of the inputs necessary for the system may be historical data which are sorted in
form of files either in terms of isolated facts or in large volumes.

Processes : this involves the programs and the way in which the data is processed through the
computer. The processing involves a set of logical steps. These steps are required to be
instructed the computer and this are done by a series of instructions called programs.

7.3. TECHNIQUES USED FOR ANALYSIS

ON-SITE OBSERVATION:

This is one of the main tools for gathering information. It is a process of recognizing and
noticing people, objects and occurrence to obtain information.

The major objective of this tool is to get as possible to the real system being studied.
For this reason it is extensively used by the system analyst during development of a particular
system.

Guidelines for on site observation:

• What kind of system is it?


• Who are important people in the system?
• Who runs the system?
• Apart from its formal function, what kind of system is it in comparison with other
system in the organization? Is it primary or secondary contributor to the organization?
It is to be kept in mind at during observation the observer has to listen more than talk and to
listen with sympathetic and genuine interest when information is being conveyed.

7.4 TYPES OF OBSERVATION METHODS

NATURAL METHODS: A natural observation occurs in a setting such as user workplace.

OBTRUSIVE METHOD: An obtrusive observation takes place when the respondent knows
he/she is being observed.

DIRECT METHOD: A direct observation takes place when the analyst actually observes the
subject or the system at work.

STRUCTURED AND UNSTRUCTURED METHOD: Incase of the structured method, the


observer looks for records and a specific action. While in case of observe whatever might be
pertinent at that time.

7.5 EXISTING SYSTEM

Existing system are the different software that provides the compression only and some
provide cryptography only .If some organization wants to send an e-mail that contains secret
data and also to reduce the size of the data then different software are to be used .One for
providing encryption and another for providing compression .This will lead to delay of time
since two different software are to be used .Also if the data type of the different software are
not compatible then it can lead to problems .Use of two different software for providing
security and compression poses different problems for the user .Various issues regarding the
use of the two different software has to be solved like compatibility of the data in the two

software .
7.6 DRAWBACKS IN EXISTING SYSTEM

 Two different software are required for the purpose of Compression and
Encryption/Decryption.

 Data type of different software may not be the same (compatibility issue)

 Using two different software requires more time as compared to using one .

 Purchasing two different software increases the budget.

 Also training on two different software has to be provided to the user.

7.7 PROPOSED SYSTEM

Proposed system is a software that provides the functionality of both the Compression and
Cryptography .There are two different modules in this proposed software one provides
security to the data via Encryption /Decryption and other reduces the size if the data by
compressing it .The main advantage of the proposed system over the existing system are stated
below

ADVANTAGES OF THE PROPOSED SYSTEM


 The proposed system will provide the functionality of both the Compression and that of
Cryptography .
 The use of one system for both compression of the data and providing security to it will
be less time consuming as compared to that of the existing system.
 The proposed system removes the compatibility issue that is prevailing when we have to
use two different software
 The use of proposed system will also reduce the budget as only one software has to be
purchased for providing both the security and compression.
 The use of the proposed system will also reduce the training as in the existing system
training on two different software are required .
DESCRIPTION OF THE ALGORITHMS USED
DATA COMPRESSION

All forms of information represented in digital form (0 or 1), such as numbers, text, sound,
image, and video-have some elements, which are redundant. We can have some equipment,
which will study or scan the information to be sent and substitute some kind of control
information to represent the repetitive data and transmit it to achieve compression. At the
other end, we can have another equipment, which will interpret these control characters and
expand the compressed data to the original form. Obviously, the addition of control
information is an overhead, but so long as the amount of data including the overhead to be
transmitted is less than the original one, compression will be beneficial.

Compression can be of two types:

1. In loss-less compression, no information is lost. All the information (that is, all the
numbers representing some text or graphic image in digital form) is compressed and
none is discarded. This type of compression is used when we must not lose or misplace
even a single bit in the original message. Examples of such messages are text-based
messages, such as funds transfer, electronic mail, documents, memos, etc.

2. In lossy compression, redundant information is discarded. This might be undesirable


in some cases, as the information being discarded during compression could be vital.
This type of compression is acceptable when the efficiency of transmission (i.e. the
amount of reduction of the size of the original message) is more important than the
accuracy of the message. Clearly, this type of compression must not be used in
text/message compression. It is more appropriate for the compression of graphics, e.g.
images, video, and sound files.

All compression systems require two algorithms: one for compressing the data at the source,
and another for decompressing it at the destination. These two algorithms are referred to as the
encoding and decoding algorithms, respectively.

DATA ENCODING SCHEMES:

The work on the exploration of efficiency, redundancy and entropy of a message has its origin
back in the 1940s. Based on all research so far, two ways of representing a character or a
symbol have emerged: static coding and dynamic coding, as shown in figure:
Data Encoding Schemes

Static Coding Dynamic Coding

STATIC CODING:

This scheme uses fixed-length codes. A fixed-length code uniquely identifies a character or
symbol. For encoding, each symbol is replaced by its corresponding code. This method is
simple. However, because it does not consider the frequency or probability of the occurrence
of the various symbols in a message, it is not very efficient.

Let us consider a message containing M different symbols. Let us assume further that N is the
number of digits needed to represent these M symbols. Let B be the base of the number
system. Then, we have the following equation:

N=logBM

We know that computers use the binary number system, which has base of 2. thus, substituting
2 for B in the above equation, we get:

N=log2M

DYNAMIC CODING:

This scheme uses variable-length codes. A variable-length code uniquely identifies a character
or symbol. For encoding, each symbol is replaced by its corresponding code. This method is
more complicated. However, because it considers the frequency or probability of the various
symbols in a message, it is not much efficient than static coding.

Variable-length codes: Let us consider an example. If we know beforehand that the character
A occurs far more frequently in our message as compared to another character X, then we
would assign a short code (i.e. lesser number of bits) to A, and a long code (i.e. more number
of bits) to X. this way, we would use less number of bits for all message, since it is likely to
contain many As than Xs.

SHANNON PRINCIPLES (SHANNON-FANO ALGORITHM):

Claude Shannon at Bell Labs and R M Fano at MIT developed the Shannon-Fano
Algorithm. The algorithm is related to the compression of text. The algorithm codifies text
into a code at the sender’s end, and transforms the code back into the original text at the
receiver’s end. The coded form needs lesser amount of space on the disk, and also while it is
being communicated, thus resulting into data compression.

SHANNON-FANO ALGORITHM:

1. Calculate the total number of distinct symbols appearing in the message/text. Also
calculate the frequency of each of them. For this use the formula:

Frequency=Number of occurrences of the symbol in the message X 100

Total number of symbols in the text

2. Arrange the symbols in the decreasing order of frequency.

3. Divide the list horizontally so that the sum of frequencies in the upper half is
approximately same as the sum of frequencies in the lower half.

4. Repeat step 3 until each half contains just one symbol.

5. Build the Shannon-Fano (SF) Tree so that the upper half becomes the left sub-tree and
the lower half becomes the right sub-tree. Ensure that all the symbols in the text are
covered.

6. Assign Shannon-Fano (SF) code to every symbol. For this, assign 0 to the left branch
and 1 to the right branch.

7. For obtaining the code for any symbol, the code is the Shannon-Fano (SF) from the
root to that leaf
HUFFMAN CODING:

The Huffman algorithm is an improvement over the Shannon-Fano algorithm. The Huffman
algorithm is also a dynamic coding mechanism, in the sense that it assigns variable-length
codes to the symbols, based on their frequencies. In that sense, it is similar to the Shannon-
Fano algorithm. Like in Shannon-Fano algorithm we build a binary tree of symbols in the case
of the Huffman algorithm as well. We also assign binary values (i.e. 0 or 1) to each node in a
similar fashion.

The Huffman algorithm thus pays due attention to the various symbols based on the likelihood
of their occurring (i.e. their frequencies). It assigns short codes to symbols occurring more
frequently, and longer codes to symbols occurring less frequently.

The major technical difference between the Shannon-Fano algorithm and the Huffman
algorithm is that the former technique builds a binary tree from the top to bottom, whereas the
latter builds it from the bottom to the top.

HUFFMAN TREE ALGORITHM:

1. Gather all the symbols and calculate their relative frequencies.

2. Arrange the symbols in the decreasing (descending) order of frequencies.

3. Construct the Huffman tree based on the symbols ordered in Step 2.

4. Allocate the codes to the nodes in the tree.

CONSTRUCTING THE HUFFMAN TREE:

1. Consider two symbols with the minimum frequencies from the sorted list of symbols.
Let us call these symbols as A and B.

2. Make A and B as two free nodes of the binary tree.


3. Assign a parent node to A and B, the value of this parent node being the sum of the
values A and B.

4. Delete node A and B.

5. Repeat steps 1 to 4 until all symbols in the list get exhausted. The outcome of this
process is the Huffman binary tree.

6. Assign bit values to the nodes of the tree, similar to the way it is done in the Shannon-
Fano tree. In other words, assign a 0 to every left node, and a 1 to every right node.

7. To find the code for any symbol, start counting from the parent and traverse from top-
to-bottom, each time reading the 0 or 1. This traversal gives the binary code for that
symbol.

ADAPTIVE COMPRESION:

Algorithm such as Shannon-Fano and Huffman use a predefined set of frequencies for
representing symbols. This is based on historical evidence and research into the way symbols
are used in a large number of sample messages. This gives an average indication about how
symbols are used, and how frequently they occur in any message. However, these numbers
may not always be true. For certain specified messages, the frequencies may greatly vary. In
such cases, it is prudent to consider frequencies, as they are likely to occur in these messages.
A technique that considers such possibilities and uses them at run-time is called as adaptive
compression technique or adaptive coding technique.
ADAPTIVE
COMPRESSION COMPRESSION
INPUT CODE INPUT CODE
MODEL MODEL

STATIC
STATIC
DATA
DATA

ADAPTIVE COMPRESSION MODEL COMPRESSION MODEL

DICTIONARY BASED COMPRESSION TECHNIQUES:

These techniques use the concept of an index. The idea behind this is quite simple. Suppose
that we have some given text, which needs to be compressed. Then we assume that a
dictionary (which is nothing but a list of words) exists for all the words in the input text. The
compression is then performed as follows: Instead of the actual words, we substitute their
positions or indexes in the dictionary in the output text.

There are various compression algorithms that make use of this technique. Some of these are
explained below:

ARITHMETIC COMPRESSION:

In this, separate algorithms are used for encoding and decoding the text/message. This makes
certain calculations with the probability associated with each symbol. This would be clearer
through the algorithms:

ARITHMETIC CODING:
Initialize

LOW_VALUE=0.0;

HIGH_VALUE=1.0;

Difference=1.0;

For every input symbol REPEAT

LOW_VALUE=LOW_VALUE+Difference*RANGE_FROM(symbol);

HIGH_VALUE=LOW_VALUE+Difference*RANGE_TO(symbol);

Difference=HIGH_VALUE-LOW_VALUE;

DISPLAY_OUTPUT(LOW_VALUE);

ARITHMETIC DECODING:

Do while(Code<>0.0)

Find the probability range where the Code falls;

Output the symbol corresponding to that range;

Code=Code-RANGE-FROM(symbol) ;

RANGE_TO(symbol)-RANGE_FROM(symbol)

LZ77 CODING:
In 1977, Abraham Lampel and Jacob Ziv proposed the first dictionary-based compression
technique, called as LZ77. the idea of this algorithm is quite simple. Suppose we want to
compress the following text:

The quick brown fox jumps over the lazy


dog
As we can see, the word ‘the’ occurs twice in the text. We can use this information to
compress the data to:

The quick brown fox jumps over * lazy


dog

Here, * is a pointer to the first four characters in the text.

LZ78 CODING:
Lampel and Ziv improved this technique the next year to come up with the LZ78 algorithm.
The main difference between the LZ77 and LZ78 algorithms is related to the use of the
dictionary. LZ77 stores the dictionary (i.e. the information regarding compression) inside the
message. However, in case of LZ78, the dictionary is maintained separately, outside of the
main text.

LZW CODING:
Terry Welch improved this algorithm further, and developed the LZW algorithm in 1984.
LZW compression replaces the strings of symbols with single codes. It does not perform any
analysis on the incoming text. Rather, it simply accumulates every new string of symbols in
stable. Compression occurs when a single code is output in the place of a series of symbols.

ADVANTAGES:

1. It produces very good results for text containing lots of repetitive data. This is often the
case with text and images.

2. LZW compression is fast.

3. LZW does not require the sender to send the dictionary along with the compressed text
to the receiver. The receiver is able to reconstruct and use the dictionary only based on
the compressed text.

DISADVANTAGES:

Royalties have to be paid to use LZW compression algorithms in our applications.

TECHNICAL DETAILS:

The LZW algorithm works in an interesting fashion. While the algorithm reads the input text,
for every symbol/character that it reads the next character immediately. It then adds these two
characters in the dictionary. For example, suppose that currently we are at the character R in a
string PQRS. Then the LZW algorithm makes an entry for RS in the dictionary. This
interesting property makes the compression process much faster and efficient. Another
important technical detail needs to be kept in mind. We know that the ASCII code has the
assigned numeric values between 0 to 255 to various symbols. Therefore, LZW algorithm uses
the first number in its dictionary as a pointer with value 256. That is, the indexing of
dictionary items starts with 256.

LZW COMPRESSION ALGORITHM:


STRING = Read input character

WHILE there are still input characters DO

CHARACTER = Read input character

IF STRING+CHARACTER is in the dictionary THEN

STRING = STRING+CHARACTER

ELSE

Output the code for STRING

Add STRING+CHARACTER to the dictionary

STRING = CHARACTER

END IF

ENDWHILE

Output the code for STRING

LZW DECOMPRESSION ALGORITHM:

Read OLD_CODE

Output OLD_CODE

WHILE there are still input characters DO

Read NEW_CODE
STRING = Get translation of NEW_CODE

Output STRING

CHARACTER = First character in STRING

Add OLD_CODE+CHARACTER to the dictionary

OLD_CODE = NEW_CODE

END of WHILE

RUN-LENGTH ENCODING:
In many kinds of data, strings of repeated symbols (bits, numbers, etc) are common. These can
replaced by a special marker not otherwise allowed in the data, followed by the symbol
comprising the run, followed by how many times it occurred. If the special marker itself
occurs in the data, it is duplicated (as in character stuffing). For example, consider the
following string of decimal digits:

3150000000000008458711111111111116354674000000000000000000000065

If we introduce A as the marker and use two-digit numbers for the repetition count, we can
encode the above digit string as

315A01284587A1136354674A02265

Here run-length encoding has cut the data string in half.

Runs are common in multimedia. In audio, runs of zeros often represent silence. In video, runs
of the same color occur in shots of the sky, walls, and many flat surfaces. All of these runs can
be greatly compressed.

THE JPEG STANDARD:


The JPEG (Joint Photographic Experts Group) standard for compressing continuous-tone still
pictures (e.g., photographs) was developed by photographic experts working under the joint
auspices of ITU, ISO, and IEC, another standards body. It is important for multimedia

BLOCK FORMATION
because, to a first approximation, the multimedia standard for moving pictures, MPEG, is just
the JPEG encoding of each frame separately, plus some extra features for interframe
compression and motion frame separately, plus some extra features for interframe
compression and motion detection. JPEG is defined in International Standard 10918.

STEPS:

DISCRETE COSINE TRANSFORMATION

QUANTIZATION

ENCODING

JPEG has many modes and many options. For our purposes, though, only the lossy sequential
mode is relevant, and that one is illustrated in Figure. Furthermore, we will concentrate on the
way JPEG is normally used to encode 24-bit RGB video images and will leave out some of the
minor details for the sake of simplicity.

Input Block Discrete Quantization Differential Run-Length Statistical


Preparation Cosine Quantization Encoding Output Output
Transform Encoding
JPEG ENCODER

JPEG DECODER

ALGORITHM:

STEP 1: This is a block preparation step. For the sake of specificity, let us assume that the
JPEG input is a 640X480 RGB image with 24 bits/pixel, as shown in the figure. Since using
luminance and chrominance gives a better compression, we first compute the luminance, Y,
and the two chrominances, I and Q (for NTSC), according to the following formulas:

Y = 0.30R+0.59G+0.11B
I = 0.60R-0.28G-0.32B
Q = 0.21R-0.52G+0.31B

For Pal, the chrominances are called U and V and the coefficients are different, but the idea is
the same. SECAM is different from both NTSC and PAL.
RGB Y I

640 640 320

………………………
…………………………. …
……………………… … 24
………………………….
.
………………………. 0
. 8Bit pixel
48 48 …
………………………
0 0 . 1 Block 24
……………………… .
0
24-Bit pixel Block 4799 Q

(a) RGB input data (b) After block preparation

Separate matrices are constructed for Y, I, and Q, each with elements in the range 0 to 255.
Next, square blocks of four pixels are averaged in the I and Q matrices to reduce them to
320X240. This reduction is lossy, but the eye barely notices it since the eye responds to
luminance more than to chrominance.

Nevertheless, it compresses the data by a factor of two. Now 128 is subtracted from each
element of all three matrices to put 0 in the middle of the range. Finally, each matrix is divided
up into 8X8 blocks. The Y matrix has 4800 blocks; the other two have 1200 blocks each, as
shown in (b).

STEP 2: This is to apply a discrete cosine transformation to each of the 7200 blocks
separately. The output of each DCT is an 8X8 matrix of DCT coefficients. DCT element (0,0)
is the average value of the block. The other elements tell how much spectral power is present
at each spatial frequency. In theory, a DCT is lossless, but in practice using floating-point
numbers and transcendental functions always introduces some roundoff error that results in a
little information loss. Normally, these elements decay rapidly with distance from the origin,
(0,0) as suggested by figure.

Fy
Y
D
C
Y/I/Q T
Amplitutde
The DCT Coefficients
One block of Y X Fx
matrix
STEP 3: This step is called Quantization, in which the less important DCT coefficients are
wiped out. This (lossy) transformation is done by dividing each of the coefficients in the 8X8
DCT matrix by a weight taken from a table. If all the weights are 1, the transformation does
nothing. However, if the weights increase sharply from the origin, higher spatial frequencies
are dropped quickly

Example:

DCT Coefficients

15 8 4 1 4 2 1 0 150 80 20 4 1 0 0 0
0 0 0 4 92 75 18 3 1 0 0 0
92 7 3 1 6 1 0 0 26 19 13 2 1 0 0 0
5 6 0
3 2 2 1 0 0 0 0
52 3 2 8 7 4 0 0
8 6 1 0 0 0 0 0 0 0

12 8 6 4 2 1 0 0 0 0 0 0 0 0 0 0

4 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0

2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0

1 1 0 0 0 0 0 0

0 0 0 0 0 0 0 0

Here we see that the initial DCT matrix, the Quantization table, and the result obtained by
dividing each DCT element by the corresponding Quantization table element. The values in
the Quantization table are not part of the JPEG standard. Each application must supply its
own, allowing it to control the loss-compression trade-off.

STEP 4: It reduces the (0,0) value of each block (the one in the upper left-hand corner) by
replacing it with the amount it differs from the corresponding element in the previous block.
Since these elements are the averages of their respective blocks, they should change slowly, so
taking the differential values should reduce most of them to small values. No differentials are
computed from the other values. The (0,0) values are referred to as the DC components; the
other values are the AC components.
STEP 5: This linearizes the 64 elements and applies run-length encoding to the list. Scanning
the block from left to right and then top to bottom will not concentrate the zeros together, so a
zig zag scanning pattern is used, as shown in the figure. In this example, the zig zag pattern
produces 38 consecutive 0s at the end of the matrix. This string can be reduced to a single
count saying there are 38 zeros.

STEP 6: Huffman encodes numbers for storage or transmission.


CRYPTOGRAPHY

There are two essential cryptographic concepts represented in the Encryption namespace. It's
important that every developer understands these concepts before proceeding any further:

1. Symmetric Cryptography

In symmetric encryption, a single key is used for encrypting and decrypting the
data. This type of encryption is quite fast, but has a severe problem: in order to share a
secret with someone, they have to know your key. This implies a very high level of
trust between people sharing secrets; if an unscrupulous person has your key-- or if
your key is intercepted by a spy-- they can decrypt all the messages you send using that
key!

2.Asymmetric Cryptography

Asymmetric encryption solves the trust problem inherent in symmetric encryption by


using two different keys: a public key for encrypting messages, and a private key
for decrypting messages. This makes it possible to communicate in secrecy with
people you don't fully trust. If an unscrupulous person has your public key, who cares?
The public key is only good for encryption; it's useless for decryption. They can't
decrypt any of your messages! However, asymmetric encryption is very slow. It's not
recommended for use on more than roughly 1 kilobyte of data.
DATA ENCRYPTION STANDARD (DES)

The Data Encryption standard (DES) is a symmetric key block cipher published by NIST
(National Institute of Standards and technology.

64 bit plain text

DES Cipher

64 bit cipher text

Encryption

The Des takes 64 bit plain text and a 56 bit key as a input and produces 64 bit cipher text as
output while encryption.

At the decryption unit 64 bit cipher text is converted back to the 64 bit plain text by using 56
bit key.The encryption process is made of two permutations boxes(P-boxes) called initial and
final permutation and sixteen fiestal rounds.Each fiestal round uses a different key (48 bit).The
initial and final permutation (P-boxes) takes 64 bit input and permute them according to the
predefined rules.The two permutations are reverse of each other.

Rounds : DES uses sixteen rounds.

The round takes L1 and R1 from previous round or from the initial permutation box at the first
round and creates l1and r1 for the next round or to the final permutation box from the last
round.The swapper unit swaps the left and right half of the text and s invertible in nature.

DES FUNCTION:

The Des function applies a 48 bit key to the rightmost 32 bits to produce 32 bit output.This
function is made up of expension P-box,XOR unit,a group of S-boxes and a straight p-box.The
32 bit is given input to expension p-box which expands the 32 bit into 48 bit.These 48 bits are
EXORed with 48 bit round key.The output of the EXORed units is feed into group of eight S-
boxes.The output of these S-boxes are 32 bit which are permuted by a straight P-box on a
predefined rule.
KEY generation of DES:

The round key generator creates sixteen 48 bit keys out of a 56 bit cipher key. The cipher key
is given as 64 bit key in which 8 extra bits are parity bits which are dropped before the actual
key generation process starts. The parity bit drop process drop the parity bits(bit
8,16,24,32…..64) and permutes the remaining bits according to the predefined rules as shown
in the parity bit drop table below. These remaining 56 bits are actually used for key
generation.

After the permutation the keys are devided into 28 bits parts. Each part is shifted left one or
two bits based on the rounds. The two parts are then combined to form a 56 bit part. Then the
compression P-box convert it into 48 bits. These 48 bits is being used as a key for a round.

STRENGTH OF DES:

The strength of DES lies on two facts: key size and nature of algorithm

The use of 56 bit key: 56 bit key is used in encryption,there are 2^56 possible keys.A brute
force attack on such number of keys is impractical.A machine performing one DES encryption
per microsecond would take more than a thousand of years to break the cipher.

The nature of algorithm: Cryptanalyst can perform cpyptanalysis by exploiting the


characteristic of DES algorithm.By exploring the weakness of eight substitution tables or S-
boxes that are used in each iteration.Much of work has been done and no. of regularities and
unexpected behaviours of the S-boxes have been discovered but no one have succeded in
finding out the weeknesses in the S-box.

TRIPLE DES:

In triple DES three stages of DES are used for encryption and decryption of messages. This
increases the security of DES. Two versions of triple DES are there:

• Triple DES with two keys.

• Triple DES with three keys.


ADVANCED ENCRYPTION STANDARD(AES)
Description:

AES is the new encryption standard being used in smart chips, cellphones, and database
encryption. It's fast and secure, and expected to become more widely used in the following
months. Unfortunately, .NET does not include AES in it's encryption library, so you will need
to implement your own class.

In cryptography, the Advanced Encryption Standard (AES) is an encryption standard adopted


by the U.S. government. The standard comprises three block ciphers, AES-128, AES-192 and
AES-256, adopted from a larger collection originally published as Rijndael. Each AES cipher
has a 128-bit block size, with key sizes of 128, 192 and 256 bits, respectively. The AES
ciphers have been analyzed extensively and are now used worldwide, as was the case with its
predecessor,[3] the Data Encryption Standard (DES)

Description of the cipher

AES is fast in both software and hardware, is relatively easy to implement, and requires little
memory Unlike its predecessor DES, AES does not use a Feistel network.

AES has a fixed block size of 128 bits and a key size of 128, 192, or 256 bits, whereas
Rijndael can be specified with block and key sizes in any multiple of 32 bits, with a minimum
of 128 bits and a maximum of 256 bits.

Assuming one byte equals 8 bits, the fixed block size of 128 bits is 128 ÷ 8 = 16 bytes. AES
operates on a 4×4 array of bytes, termed the state (versions of Rijndael with a larger block size
have additional columns in the state). Most AES calculations are done in a special finite field.

The AES cipher is specified as a number of repetitions of transformation rounds that convert
the input plain-text into the final output of cipher-text. Each round consists of several
processing steps, including one that depends on the encryption key.

A set of reverse rounds are applied to transform cipher-text back into the original plain-text
using the same encryption key.

ALGORITHM:

The SubBytes step:

In the SubBytes step, each byte in the array is updated using an 8-bit substitution box, the
Rijndael S-box. This operation provides the non-linearity in the cipher. The S-box used is
derived from the multiplicative inverse over GF(28), known to have good non-linearity
properties. To avoid attacks based on simple algebraic properties, the S-box is constructed by
combining the inverse function with an invertible affine transformation. The S-box is also
chosen to avoid any fixed points (and so is a derangement), and also any opposite fixed points

The ShiftRows step :

In the ShiftRows step, bytes in each row of the state are shifted cyclically to the left. The
number of places each byte is shifted differs for each row.

The ShiftRows step operates on the rows of the state; it cyclically shifts the bytes in each row
by a certain offset. For AES, the first row is left unchanged. Each byte of the second row is
shifted one to the left. Similarly, the third and fourth rows are shifted by offsets of two and
three respectively. For the block of size 128 bits and 192 bits the shifting pattern is the same.
In this way, each column of the output state of the ShiftRows step is composed of bytes from
each column of the input state. (Rijndael variants with a larger block size have slightly
different offsets). In the case of the 256-bit block, the first row is unchanged and the shifting
for second, third and fourth row is 1 byte, 3 bytes and 4 bytes respectively - although this
change only applies for the Rijndael cipher when used with a 256-bit block, which is not used
for AES.
The MixColumns step:

In the MixColumns step, each column of the state is multiplied with a fixed polynomial c(x).

In the MixColumns step, the four bytes of each column of the state are combined using an
invertible linear transformation. The MixColumns function takes four bytes as input and
outputs four bytes, where each input byte affects all four output bytes. Together with
ShiftRows, MixColumns provides diffusion in the cipher. Each column is treated as a
polynomial over GF(28) and is then

multiplied modulo x4 + 1 with a fixed polynomial c(x) = 3x3 + x2 + x + 2. The MixColumns


step can also be viewed as a multiplication by a particular MDS matrix in Finite field. This
process is described further in the article

The AddRoundKey step:

In the AddRoundKey step, each byte of the state is combined with a byte of the round subkey
using the XOR operation .

In the AddRoundKey step, the subkey is combined with the state. For each round, a subkey is
derived from the main key using Rijndael's key schedule; each subkey is the same size as the
state. The subkey is added by combining each byte of the state with the corresponding byte of
the subkey using bitwise XOR.
Optimization of the cipher

On systems with 32-bit or larger words, it is possible to speed up execution of this cipher by
combining SubBytes and ShiftRows with MixColumns, and transforming them into a
sequence of table lookups. This requires four 256-entry 32-bit tables, which utilizes a total of
four kilobytes (4096 bytes) of memory—one kilobyte for each table. A round can now be done
with 16 table lookups and 12 32-bit exclusive-or operations, followed by four 32-bit
exclusive-or operations in the AddRoundKey step.

If the resulting four kilobyte table size is too large for a given target platform, the table lookup
operation can be performed with a single 256-entry 32-bit table by the use of circular
rotates.Using a byte-oriented approach it is possible to combine the SubBytes, ShiftRows,
and MixColumns steps into a single round operation.
DIGITAL IMAGES

Introduction

When using digital equipment to capture, store, modify and view photographic
images, they must first be converted to a set of numbers in a process called digitization
or scanning. Computers are very good at storing and manipulating numbers, so
once your image has been digitized you can use your computer to archive, examine,
alter, display, transmit, or print your photographs in an incredible variety of ways.

Pixels and Bitmaps

Digital images are composed of pixels (short for picture elements). Each pixel represents
the color (or gray level for black and white photos) at a single point in the
image, so a pixel is like a tiny dot of a particular color. By measuring the color of an
image at a large number of points, we can create a digital approximation of the image
from which a copy of the original can be reconstructed. Pixels are a little like grain
particles in a conventional photographic image, but arranged in a regular pattern of
rows and columns and store information somewhat differently. A digital image is a
rectangular array of pixels sometimes called a bitmap.

STEGANOGRAPHY
I. Introduction

This paper's focus is on a relatively new field of study in Information Technology known
as Steganography. This paper will take an in-depth look at this technology by ntroducing
the reader to various concepts of Steganography, a brief history of Steganography and a look
at some of the Steganographic techniques available today. The paper will close by looking at
how we can use Steganography in an open-systems environment such as the Internet, as well
as some of the tools and resources available to help us accomplish this.

II. A Detailed Look at Steganography

In this section we will discuss Steganography at length. We will start by looking at the
different types of Steganography generally used in practice today along with some of the other
principles that are used in Steganography. We will then look at some of the
Steganographic techniques in use today. This is where we will look at the nuts and bolts
of Steganography and all the different ways we can use this technology. We will then
close by going over Steganalysis. Steganalysis concentrates on the art and science of
finding and or destroying secret messages that have been produced using any of the
various steganographic techniques we will cover in this paper.
To start, lets look at what a theoretically perfect secret communication (Steganography)
would consist of. To illustrate this concept, we will use three fictitious characters named
Amy, Bret and Crystal. Amy wants to send a secret message (M) to Bret using a random (R)
harmless message to create a cover (C) which can be sent to Bret without raising suspicion.
Amy then changes the cover message (C) to a stego-object (S) by embedding the secret
message (M) into the cover message (C) by using a stego-key (K). Amy should then be able to
send the stegoobject (S) to Bret without being detected by Crystal. Bret will then be able to
read the secret message (M) because he knows the stego-key (K) used to embed it into the
cover message (C). As Fabien A.P. Petitcolas [2] points out, "in a 'perfect' system, a normal
cover should not be distinguishable from a stego-object, neither by a human nor by a computer
looking for statistical patterns." In practice, however, this is not always the case. In order to
embed secret data into a cover message, the cover must contain a sufficient amount of
redundant data or noise. This is because the embedding process Steganography uses, actually
replaces this redundant data with the secret message. This limits the types of data that we can
use with Steganography.
In practice, there are basically three types of steganographic protocols used. They are
Pure Steganography, Secret Key Steganography and Public Key Steganography.
Pure Steganography is defined as a steganographic system that does not require the
exchange of a cipher such as a stego-key. This method of Steganography is the least
secure means by which to communicate secretly because the sender and receiver can rely only
upon the presumption that no other parties are aware of this secret message. Using open
systems such as the Internet, we know this is not the case at all.
Secret Key Steganography is defined as a steganographic system that requires the
exchange of a secret key (stego-key) prior to communication. Secret Key Steganography takes
a cover message and embeds the secret message inside of it by using a secret key (stego-key).
Only the parties who know the secret key can reverse the process and read the secret message.
Unlike Pure Steganography where a perceived invisible communication channel is present,
Secret Key Steganography exchanges a stego-key, which makes it more susceptible to
interception. The benefit to Secret Key Steganography is even if it is intercepted, only parties
who know the secret key can extract the secret message. Public Key Steganography takes the
concepts from Public Key Cryptography as explained below. Public Key Steganography is
defined as a steganographic system that uses a public key and a private key to secure the
communication between the parties wanting to communicate secretly. The sender will use the
public key during the encoding process and only the private key, which has a direct
mathematical relationship with the public key, can decipher the secret message. Public Key
Steganography provides a more robust way of implementing a steganographic system because
it can utilize a much more robust and researched technology in Public Key Cryptography. It
also has multiple levels of security in that unwanted parties must first suspect the use of
steganography and then they would have to find a way to crack the algorithm used by the
public key system before they could intercept the secret message.

A. Encoding Secret Messages in Text

Encoding secret messages in text can be a very challenging task. This is because
text files have a very small amount of redundant data to replace with a secret message.
Another drawback is the ease of which text based Steganography can be altered by an
unwanted parties by just changing the text itself or reformatting the text to some other
form (from .TXT to .PDF, etc.). There are numerous methods by which to accomplish
text based Steganography. I will introduce a few of the more popular encoding methods
below.
= AF19 FA27 2F94 998D FDB5 DE3D F8B5 06E4 A169 4E46
Line-shift encoding involves actually shifting each line of text vertically up or
down by as little as 3 centimeters. Depending on whether the line was up or down from
the stationary line would equate to a value that would or could be encoded into a secret
message.
Word-shift encoding works in much the same way that line-shift encoding works,
only we use the horizontal spaces between words to equate a value for the hidden
message. This method of encoding is less visible than line-shift encoding but requires that the
text format support variable spacing.
Feature specific encoding involves encoding secret messages into formatted text
by changing certain text attributes such as vertical/horizontal length of letters such as b,
d, T, etc. This is by far the hardest text encoding method to intercept as each type of
formatted text has a large amount of features that can be used for encoding the secret
message. All three of these text based encoding methods require either the original file or the
knowledge of the original files formatting to be able to decode the secret message.

B. Encoding Secret Messages in Image

Coding secret messages in digital images is by far the most widely used of all
methods in the digital world of today. This is because it can take advantage of the limited
power of the human visual system (HVS). Almost any plain text, cipher text, image and any
other media that can be encoded into a bit stream can be hidden in a digital image. With the
continued growth of strong graphics power in computers and the research being put into image
based Steganography, this field will continue to grow at a very rapid pace. Before diving into
coding techniques for digital images, a brief explanation of digital image architecture and
digital image compression techniques should be explained. As Duncan Sellars [7] explains
"To a computer, an image is an array of numbers that represent light intensities at various
points, or pixels. These pixels make up the images raster data." When dealing with digital
images for use with Steganography, 8-bit and 24-bit per pixel image files are typical. Both
have advantages and disadvantages, as we will explain below. 8-bit images are a great format
to use because of their relatively small size. The drawback is that only 256 possible colors can
be used which can be a potential problem during encoding. Usually a gray scale color palette
is used when dealing with 8-bit images such as (.GIF) because its gradual change in color will
be harder to detect after the image has been encoded with the secret message. 24-bit images
offer much more flexibility when used for Steganography. The large numbers of colors (over
16 million) that can be used
go well beyond the human visual system (HVS), which makes it very hard to detect once a
secret message, has been encoded. The other benefit is that a much larger amount of hidden
data can be encoded into a 24-bit digital image as opposed to an 8-bit digital image. The one
major drawback to 24-bit digital images is their large size (usually in MB) makes them more
suspect than the much smaller 8-bit digital images (usually in
KB) when sent over an open system such as the Internet. Digital image compression is a good
solution to large digital images such as the 24-bit images mentioned earlier. There are two
types of compression used in digital images, lossy and lossless. Lossy compression such as
(.JPEG) greatly reduces the size of a digital image by removing excess image data and
calculating a close approximation of the original image. Lossy compression is usually used
with 24-bit digital images to reduce its size, but it does carry one major drawback. Lossy
compression techniques increase the possibility that the uncompressed secret message will
lose parts of its contents because of the fact that lossy compression removes what it sees as
excess image data. Lossless compression techniques, as the name suggests, keeps the original
digital image in tact without the chance of loss. It is for this reason that it is the compression
technique of choice for steganographic uses. Examples of lossless compression techniques are
(.GIF and .BMP). The only drawback to lossless image compression is that it doesn't do a very
good job at compressing the size of the image data.
We will now discuss a couple of the more popular digital image encoding techniques used
today. They are least significant bit (LSB) encoding and masking and filtering techniques.
Least significant bit (LSB) encoding is by far the most popular of the coding techniques used
for digital images. By using the LSB of each byte (8 bits) in an image for a secret message,
you can store 3 bits of data in each pixel for 24-bit images and 1 bit in each pixel for 8-bit
images. As you can see, much more information can be stored in a 24-bit image file.
Depending on the color palette used for the cover image (i.e., all gray), it is possible to take 2
LSB's from one byte without the human visual system (HVS) being able to tell the difference.
The only problem with this technique is that it is very vulnerable to attacks such as image
changes and formatting (i.e., changing from .GIF to .JPEG).
Masking and filtering techniques for digital image encoding such as Digital
Watermarking (i.e.- integrating a companies logo on there web content) are more popular with
lossy compression techniques such as (.JPEG). This technique actually extends an images data
by masking the secret data over the original data as opposed to hiding information inside of
the data. Some experts argue that this is definitely a form of Information Hiding, but not
technically Steganography. The beauty of Masking and
Filtering techniques are that they are immune to image manipulation which makes there
possible uses very robust.
There are techniques that use complex algorithms, image transformation techniques and image
encryption techniques which are still, relatively new, but show promise to be more secure and
robust ways to use digital images in Steganography.

COLOR MATRIX
INTRODUCTION:

This article discusses color operations on digital images, using the new ColorMatrix class
provided by GDI+. The ColorMatrix is a welcome addition to the GDI library, especially with
the increase in demand of digital imaging applications, as more and more consumer products
are made available. This class, as well as many other new GDI classes, provide more control
to the developer and reduce dependence on 3rd party applications such as LEAD tools, and
others. Some basic knowledge of matrix operations (multiplication, addition, etc), the RGBA
colorspace and GDI+ is assumed.

BACKGROUND:

ColorMatrix operations are performed in the RGBA colorspace (red, green, blue, alpha). A
ColorMatrix consists of a 5x5 matrix, with color values normalized to 1 for full intensity (255
-> 1.0). You might expect the matrix to be 4x4 ( [R, G, B, A] ), which would be sufficient if
we only needed to perform linear transformations (multiplication: scaling, rotation, etc).
However, one of the most frequent color manipulations, color adjustment, requires adding
color values. This is a non-linear operation, referred to as a translation. Adding a 5th element
to the color vector ( [R, G, B, A, w] ) combines these two operations, linear and non-linear,
into a single operation called an affine transformation. The 5th element of the color vector is
simply a dummy element, always with a value of 1, which only serves to allow a translation
(addition) of the color vector.

The example below scales the color vector [255, 128, 102, 255] by .5 and then adds a value of
26 to the R, G and B components, leaving the A component at full intensity. Remember that
the component values are normalized, with full intensity, 255, equal to 1.0 (values have been
rounded to the nearest tenth). Also notice the addition of the 5th element to the color vector,
which is simply ignored in the resultant color vector.

This takes the color and transforms it to .

Now that we've covered the basic principle of the ColorMatrix and it's operations on color
vectors, we can start exploring some practical uses.
DESIGN
DATA FLOW DIAGRAMS
What is DFD:-

A Data Flow Diagram is a graphical technique that depicts information flow and
the transform that are applied as data moves from input to output.The Data Flow Diagram is
also known as Data Flow Graph or Bubble chart

The DFD serves two purpose:-

(1)To provide an indication of how data is transformed as they move through the system

(2) To depict the function and sub function that transform the data

The Dfd provides additional information that is used during the analysis of the information
domain and serves as basis for modeling of function. The data flow diagram may be portioned
into levels that represents increasing information flow and function call.The DFD may be
divided into many levels-

(1)0 level DFD(CAD)-In zero level DFD we represent whole system and its external entities
with Data Flow it is also called Context Analysis Diagram.

(2)1 level DFD might contain 5 or 6 bubbles with interconnecting arrows

(3)Then after one level DFD it can again further enlarge make the expanded DFD

ZERO LEVEL DATA FLOW DIAGRAM


COMPRESSE
D DATA

INPUT

ENCRYPTE
D DATA
COMPRESSION (JPEG,
LZW, RUN-LENGTH
ENCODING, FORMAT COMPRESSED
CONVERSION) DATA(IMAGE,
TEXT)
INPUT (TEXT,
IMAGES)

CRYPTOGRAPHY
(DES, AES,
TRANSPOSITION,
TRIPLE DES, UNREADABLE
STEGNOGRAPHY) /HIDDEN MESSAGE

LEVEL 1 DATA FLOW DIAGRAM


CODING
SPLASHSCREEN.VB

Public NotInheritable Class SplashScreen1

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value += 2

If ProgressBar1.Value <= 30 Then

Label6.Text = “Initialized Application …..”

ElseIf ProgressBar1.Value <= 50 Then

Label6.Text = “Loading Algorithm”

ElseIf ProgressBar1.Value <= 70 Then

Label6.Text = “Loading Forms”

ElseIf ProgressBar1.Value <= 100 Then

Label6.Text = “Please Wait ….”

End If

If ProgressBar1.Value = 100 Then

Timer1.Dispose()

Me.Visible = False
Form1.Show()

End If
End Sub

Private Sub SplashScreen1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label8.Click

End Sub
End Class
FORM1.VB
Imports System.Drawing.Imaging
Imports system.threading
Public Class Form1

Private Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs)
Dim f As New Transposition
f.Show()

End Sub

Private Sub textcompress_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New textfilecompress
f.Show()
End Sub

Private Sub Jpeg1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New jpeg1
f.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New imageformat
f.Show()

End Sub

Private Sub textsteg_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New teststegano
f.Show()
End Sub

Private Sub encr_file_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New fileencrypt
f.Show()
End Sub

Private Sub stringcomprcry_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs)
Dim f As New stringcomcry
f.Show()

End Sub

Private Sub sdes_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New DES1
f.Show()
End Sub

Private Sub img_steg_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
'Dim f As New ALAAJUBRAN
'f.Show()

End Sub

Private Sub Jpeg_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New jpeg
f.Show()

End Sub

Private Sub fileDES_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New fileDES
f.Show()

End Sub

Private Sub submit_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles submit.Click
If RadioButton1.Checked Then
Dim f As New compressionpage
f.Show()
ElseIf RadioButton2.Checked Then
Dim f As New cryptopage
f.Show()
Else
MessageBox.Show("Please Choose an Option")

End If
End Sub

Private Sub Bexit_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Bexit.Click
Application.Exit()
End Sub

Private m_Alpha As Single = 0 ' Alpha on a 0-1 scale.


Private m_DAlpha As Single = 0.05

Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

picResult.Image = bm
picResult.Refresh()

m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Dim dt As DateTime = DateTime.Now
Dim t As Date
Thread.CurrentThread.CurrentCulture = New
Globalization.CultureInfo("en-US")
t = TimeOfDay
ltime.Text = t
ldate.Text = dt.ToString("d")
Dim s, r As String
s = Mid(t.ToString(), 19, 2)
r = Mid(t.ToString(), 18, 2)
If (s = "AM" Or r = "AM") Then
lwish.Text = "Good Morning !!"
ElseIf (s = "PM" Or r = "PM") Then
If Hour(t) < 4 Or Hour(t) = 12 Then
lwish.Text = "Good Afternoon !!"
Else
lwish.Text = "Good Evening !!"
End If
End If

End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Dim t As Date

t = TimeOfDay
ltime.Text = t
End Sub
End Class
IMAGEANALYSER.VB
Imports System

Imports System.Text

Imports System.Drawing

Imports System.Drawing.Imaging

Imports System.Collections

Imports System.ComponentModel

Imports System.Windows.Forms

Imports System.Data

Public Class imageanalyservb


Inherits System.Windows.Forms.Form
Public Sub New()
InitializeComponent()
End Sub
#Region "Windows Form Designer generated code"

Private Sub InitializeComponent()


Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager =
New System.ComponentModel.ComponentResourceManager(GetType(imageanalyservb))
Me.textBox1 = New System.Windows.Forms.TextBox
Me.button1 = New System.Windows.Forms.Button
Me.button2 = New System.Windows.Forms.Button
Me.Panel2 = New System.Windows.Forms.Panel
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.tmrDisplayFrame = New System.Windows.Forms.Timer(Me.components)
Me.picSrc2 = New System.Windows.Forms.PictureBox
Me.picSrc1 = New System.Windows.Forms.PictureBox
Me.Panel1 = New System.Windows.Forms.Panel
Me.picResult = New System.Windows.Forms.PictureBox
Me.Panel2.SuspendLayout()
CType(Me.picSrc2,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.picSrc1,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.Panel1.SuspendLayout()
CType(Me.picResult,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
Me.textBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.textBox1.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.textBox1.Font = New System.Drawing.Font("Courier New", 8.25!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.textBox1.Location = New System.Drawing.Point(225, 142)
Me.textBox1.Multiline = True
Me.textBox1.Name = "textBox1"
Me.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.textBox1.Size = New System.Drawing.Size(579, 446)
Me.textBox1.TabIndex = 0
Me.textBox1.Visible = False
Me.button1.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.button1.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.button1.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.button1.ForeColor = System.Drawing.Color.Navy
Me.button1.Location = New System.Drawing.Point(448, 335)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(114, 56)
Me.button1.TabIndex = 1
Me.button1.Text = "Browse Image >>"
Me.button1.UseVisualStyleBackColor = False
Me.button2.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.button2.Location = New System.Drawing.Point(717, 224)
Me.button2.Name = "button2"
Me.button2.Size = New System.Drawing.Size(75, 23)
Me.button2.TabIndex = 2
Me.button2.Text = "Quit"
Me.button2.Visible = False
Me.Panel2.BackColor = System.Drawing.Color.FromArgb(CType(CType(255,
Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(128, Byte),
Integer))
Me.Panel2.Controls.Add(Me.Label1)
Me.Panel2.Controls.Add(Me.Label2)
Me.Panel2.Controls.Add(Me.picSrc2)
Me.Panel2.Controls.Add(Me.picSrc1)
Me.Panel2.Location = New System.Drawing.Point(-3, 142)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(227, 446)
Me.Panel2.TabIndex = 29
'
Me.Label1.AutoSize = True
Me.Label1.BackColor = System.Drawing.Color.Navy
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif",
12.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(192,
Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(255, Byte),
Integer))
Me.Label1.Location = New System.Drawing.Point(63, 7)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(170, 20)
Me.Label1.TabIndex = 30
Me.Label1.Text = "Image Description >>"
Me.Label1.Visible = False
Me.Label2.AutoSize = True
Me.Label2.ForeColor = System.Drawing.Color.Navy
Me.Label2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label2.Location = New System.Drawing.Point(-3, 57)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(189, 169)
Me.Label2.TabIndex = 25
Me.Label2.Text = resources.GetString("Label2.Text")
Me.tmrDisplayFrame.Enabled = True
Me.tmrDisplayFrame.Interval = 50
Me.picSrc2.Image = CType(resources.GetObject("picSrc2.Image"),
System.Drawing.Image)
Me.picSrc2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picSrc2.Location = New System.Drawing.Point(15, 345)
Me.picSrc2.Name = "picSrc2"
Me.picSrc2.Size = New System.Drawing.Size(100, 50)
Me.picSrc2.TabIndex = 27
Me.picSrc2.TabStop = False
Me.picSrc2.Visible = False
Me.picSrc1.Image = CType(resources.GetObject("picSrc1.Image"),
System.Drawing.Image)
Me.picSrc1.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picSrc1.Location = New System.Drawing.Point(15, 289)
Me.picSrc1.Name = "picSrc1"
Me.picSrc1.Size = New System.Drawing.Size(100, 50)
Me.picSrc1.TabIndex = 26
Me.picSrc1.TabStop = False
Me.picSrc1.Visible = False

Me.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0,
Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(192, Byte),
Integer))
Me.Panel1.BackgroundImage =
Global.DCC_final.My.Resources.Resources.untitled21
Me.Panel1.BackgroundImageLayout =
System.Windows.Forms.ImageLayout.Stretch
Me.Panel1.Controls.Add(Me.picResult)
Me.Panel1.ForeColor = System.Drawing.Color.White
Me.Panel1.Location = New System.Drawing.Point(-3, -1)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(810, 147)
Me.Panel1.TabIndex = 25
'
Me.picResult.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picResult.Location = New System.Drawing.Point(228, 0)
Me.picResult.Name = "picResult"
Me.picResult.Size = New System.Drawing.Size(646, 147)
Me.picResult.TabIndex = 20
Me.picResult.TabStop = False
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte),
Integer), CType(CType(255, Byte), Integer), CType(CType(128, Byte),
Integer))
Me.ClientSize = New System.Drawing.Size(805, 587)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.button2)
Me.Controls.Add(Me.button1)
Me.Controls.Add(Me.textBox1)
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.SizableToolWindow
Me.Name = "imageanalyservb"
Me.Text = "r"
Me.Panel2.ResumeLayout(False)
Me.Panel2.PerformLayout()
CType(Me.picSrc2,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.picSrc1,
System.ComponentModel.ISupportInitialize).EndInit()
Me.Panel1.ResumeLayout(False)
CType(Me.picResult,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Private m_Alpha As Single = 0 Private m_DAlpha As Single = 0.05

Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

picResult.Image = bm
picResult.Refresh()

m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

#End Region

<STAThread()> _
Private Shared Sub Main()

Application.Run(New imageanalyservb())
End Sub

Private Function DumpValues(ByVal v As Byte()) As String

Dim sb As New StringBuilder()

Dim index1 As Integer = 0

Dim index2 As Integer = 0

For index1 = 0 To v.Length - 1 Step 16

sb.Append(vbTab)

For index2 = 0 To 15

If index1 + index2 < v.Length Then

sb.Append(v(index1 + index2).ToString("X02") & " ")


Else

sb.Append(" ")

End If
Next

sb.Append(vbTab)

For index2 = 0 To 15

If index1 + index2 < v.Length Then

Dim c As Char = CType(ChrW(v(index1 + index2)), Char)


If (c < "&H20") Then

sb.Append(".")
Else

sb.Append(c)

End If

End If
Next

sb.Append(vbCr & vbLf)


Next

Return sb.ToString()
End Function

Private Sub button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles button1.Click

Dim dlg As New OpenFileDialog()

dlg.Filter = "Image files|*.tif;*.jpg;*.jpeg;*.bmp;*.tiff;*.gif"

If dlg.ShowDialog() = DialogResult.OK Then

Dim img As Image = Image.FromFile(dlg.FileName)

Me.textBox1.Text = ""

Dim sb As New StringBuilder()


sb.Append(String.Format("Image: {0}" & vbCr & vbLf & "Width=
{1}, Height= {2}" & vbCr & vbLf & "PixelFormat = {3}" & vbCr & vbLf &
"Dumping {4} property items:", dlg.FileName, img.Width, img.Height,
img.PixelFormat, img.PropertyItems.Length))

For Each i As PropertyItem In img.PropertyItems

Dim s As String = "UnknownTag"

Select Case i.Id

Case &H0

s = "PropertyTagGpsVer "

Exit Select

Case &H1

s = "PropertyTagGpsLatitudeRef "

Exit Select

Case &H2

s = "PropertyTagGpsLatitude "

Exit Select

Case &H3

s = "PropertyTagGpsLongitudeRef "

Exit Select

Case &H4

s = "PropertyTagGpsLongitude "

Exit Select

Case &H5

s = "PropertyTagGpsAltitudeRef "

Exit Select

Case &H6

s = "PropertyTagGpsAltitude "

Exit Select

Case &H7

s = "PropertyTagGpsGpsTime "
Exit Select

Case &H8

s = "PropertyTagGpsGpsSatellites "

Exit Select

Case &H9

s = "PropertyTagGpsGpsStatus "

Exit Select

Case &HA

s = "PropertyTagGpsGpsMeasureMode "

Exit Select

Case &HB

s = "PropertyTagGpsGpsDop "

Exit Select

Case &HC

s = "PropertyTagGpsSpeedRef "

Exit Select

Case &HD

s = "PropertyTagGpsSpeed "

Exit Select

Case &HE

s = "PropertyTagGpsTrackRef "

Exit Select

Case &HF

s = "PropertyTagGpsTrack "

Exit Select

Case &H10

s = "PropertyTagGpsImgDirRef "

Exit Select
Case &H11

s = "PropertyTagGpsImgDir "

Exit Select

Case &H12

s = "PropertyTagGpsMapDatum "

Exit Select

Case &H13

s = "PropertyTagGpsDestLatRef "

Exit Select

Case &H14

s = "PropertyTagGpsDestLat "

Exit Select

Case &H15

s = "PropertyTagGpsDestLongRef "

Exit Select

Case &H16

s = "PropertyTagGpsDestLong "

Exit Select

Case &H17

s = "PropertyTagGpsDestBearRef "

Exit Select

Case &H18

s = "PropertyTagGpsDestBear "

Exit Select

Case &H19

s = "PropertyTagGpsDestDistRef "

Exit Select

Case &H1A
s = "PropertyTagGpsDestDist "

Exit Select

Case &HFE

s = "PropertyTagNewSubfileType "

Exit Select

Case &HFF

s = "PropertyTagSubfileType "

Exit Select

Case &H100

s = "PropertyTagImageWidth "

Exit Select

Case &H101

s = "PropertyTagImageHeight "

Exit Select

Case &H102

s = "PropertyTagBitsPerSample "

Exit Select

Case &H103

s = "PropertyTagCompression "

Exit Select

Case &H106

s = "PropertyTagPhotometricInterp "

Exit Select

Case &H107

s = "PropertyTagThreshHolding "

Exit Select

Case &H108

s = "PropertyTagCellWidth "
Exit Select

Case &H109

s = "PropertyTagCellHeight "

Exit Select

Case &H10A

s = "PropertyTagFillOrder "

Exit Select

Case &H10D

s = "PropertyTagDocumentName "

Exit Select

Case &H10E

s = "PropertyTagImageDescription "

Exit Select

Case &H10F

s = "PropertyTagEquipMake "

Exit Select

Case &H110

s = "PropertyTagEquipModel "

Exit Select

Case &H111

s = "PropertyTagStripOffsets "

Exit Select

Case &H112

s = "PropertyTagOrientation "

Exit Select

Case &H115

s = "PropertyTagSamplesPerPixel "

Exit Select
Case &H116

s = "PropertyTagRowsPerStrip "

Exit Select

Case &H117

s = "PropertyTagStripBytesCount "

Exit Select

Case &H118

s = "PropertyTagMinSampleValue "

Exit Select

Case &H119

s = "PropertyTagMaxSampleValue "

Exit Select

Case &H11A

s = "PropertyTagXResolution "

Exit Select

Case &H11B

s = "PropertyTagYResolution "

Exit Select

Case &H11C

s = "PropertyTagPlanarConfig "

Exit Select

Case &H11D

s = "PropertyTagPageName "

Exit Select

Case &H11E

s = "PropertyTagXPosition "

Exit Select

Case &H11F
s = "PropertyTagYPosition "

Exit Select

Case &H120

s = "PropertyTagFreeOffset "

Exit Select

Case &H121

s = "PropertyTagFreeByteCounts "

Exit Select

Case &H122

s = "PropertyTagGrayResponseUnit "

Exit Select

Case &H123

s = "PropertyTagGrayResponseCurve "

Exit Select

Case &H124

s = "PropertyTagT4Option "

Exit Select

Case &H125

s = "PropertyTagT6Option "

Exit Select

Case &H128

s = "PropertyTagResolutionUnit "

Exit Select

Case &H129

s = "PropertyTagPageNumber "

Exit Select

Case &H12D

s = "PropertyTagTransferFunction "
Exit Select

Case &H131

s = "PropertyTagSoftwareUsed "

Exit Select

Case &H132

s = "PropertyTagDateTime "

Exit Select

Case &H13B

s = "PropertyTagArtist "

Exit Select

Case &H13C

s = "PropertyTagHostComputer "

Exit Select

Case &H13D

s = "PropertyTagPredictor "

Exit Select

Case &H13E

s = "PropertyTagWhitePoint "

Exit Select

Case &H13F

s = "PropertyTagPrimaryChromaticities "

Exit Select

Case &H140

s = "PropertyTagColorMap "

Exit Select

Case &H141

s = "PropertyTagHalftoneHints "

Exit Select
Case &H142

s = "PropertyTagTileWidth "

Exit Select

Case &H143

s = "PropertyTagTileLength "

Exit Select

Case &H144

s = "PropertyTagTileOffset "

Exit Select

Case &H145

s = "PropertyTagTileByteCounts "

Exit Select

Case &H14C

s = "PropertyTagInkSet "

Exit Select

Case &H14D

s = "PropertyTagInkNames "

Exit Select

Case &H14E

s = "PropertyTagNumberOfInks "

Exit Select

Case &H150

s = "PropertyTagDotRange "

Exit Select

Case &H151

s = "PropertyTagTargetPrinter "

Exit Select

Case &H152
s = "PropertyTagExtraSamples "

Exit Select

Case &H153

s = "PropertyTagSampleFormat "

Exit Select

Case &H154

s = "PropertyTagSMinSampleValue "

Exit Select

Case &H155

s = "PropertyTagSMaxSampleValue "

Exit Select

Case &H156

s = "PropertyTagTransferRange "

Exit Select

Case &H200

s = "PropertyTagJPEGProc "

Exit Select

Case &H201

s = "PropertyTagJPEGInterFormat "

Exit Select

Case &H202

s = "PropertyTagJPEGInterLength "

Exit Select

Case &H203

s = "PropertyTagJPEGRestartInterval "

Exit Select

Case &H205

s = "PropertyTagJPEGLosslessPredictors "
Exit Select

Case &H206

s = "PropertyTagJPEGPointTransforms "

Exit Select

Case &H207

s = "PropertyTagJPEGQTables "

Exit Select

Case &H208

s = "PropertyTagJPEGDCTables "

Exit Select

Case &H209

s = "PropertyTagJPEGACTables "

Exit Select

Case &H211

s = "PropertyTagYCbCrCoefficients "

Exit Select

Case &H212

s = "PropertyTagYCbCrSubsampling "

Exit Select

Case &H213

s = "PropertyTagYCbCrPositioning "

Exit Select

Case &H214

s = "PropertyTagREFBlackWhite "

Exit Select

Case &H301

s = "PropertyTagGamma "

Exit Select
Case &H302

s = "PropertyTagICCProfileDescriptor "

Exit Select

Case &H303

s = "PropertyTagSRGBRenderingIntent "

Exit Select

Case &H320

s = "PropertyTagImageTitle "

Exit Select

Case &H5001

s = "PropertyTagResolutionXUnit "

Exit Select

Case &H5002

s = "PropertyTagResolutionYUnit "

Exit Select

Case &H5003

s = "PropertyTagResolutionXLengthUnit "

Exit Select

Case &H5004

s = "PropertyTagResolutionYLengthUnit "

Exit Select

Case &H5005

s = "PropertyTagPrintFlags "

Exit Select

Case &H5006

s = "PropertyTagPrintFlagsVersion "

Exit Select

Case &H5007
s = "PropertyTagPrintFlagsCrop "

Exit Select

Case &H5008

s = "PropertyTagPrintFlagsBleedWidth "

Exit Select

Case &H5009

s = "PropertyTagPrintFlagsBleedWidthScale "

Exit Select

Case &H500A

s = "PropertyTagHalftoneLPI "

Exit Select

Case &H500B

s = "PropertyTagHalftoneLPIUnit "

Exit Select

Case &H500C

s = "PropertyTagHalftoneDegree "

Exit Select

Case &H500D

s = "PropertyTagHalftoneShape "

Exit Select

Case &H500E

s = "PropertyTagHalftoneMisc "

Exit Select

Case &H500F

s = "PropertyTagHalftoneScreen "

Exit Select

Case &H5010

s = "PropertyTagJPEGQuality "
Exit Select

Case &H5011

s = "PropertyTagGridSize "

Exit Select

Case &H5012

s = "PropertyTagThumbnailFormat "

Exit Select

Case &H5013

s = "PropertyTagThumbnailWidth "

Exit Select

Case &H5014

s = "PropertyTagThumbnailHeight "

Exit Select

Case &H5015

s = "PropertyTagThumbnailColorDepth "

Exit Select

Case &H5016

s = "PropertyTagThumbnailPlanes "

Exit Select

Case &H5017

s = "PropertyTagThumbnailRawBytes "

Exit Select

Case &H5018

s = "PropertyTagThumbnailSize "

Exit Select

Case &H5019

s = "PropertyTagThumbnailCompressedSize "

Exit Select
Case &H501A

s = "PropertyTagColorTransferFunction "

Exit Select

Case &H501B

s = "PropertyTagThumbnailData "

Exit Select

Case &H5020

s = "PropertyTagThumbnailImageWidth "

Exit Select

Case &H5021

s = "PropertyTagThumbnailImageHeight "

Exit Select

Case &H5022

s = "PropertyTagThumbnailBitsPerSample "

Exit Select

Case &H5023

s = "PropertyTagThumbnailCompression "

Exit Select

Case &H5024

s = "PropertyTagThumbnailPhotometricInterp "

Exit Select

Case &H5025

s = "PropertyTagThumbnailImageDescription "

Exit Select

Case &H5026

s = "PropertyTagThumbnailEquipMake "

Exit Select

Case &H5027
s = "PropertyTagThumbnailEquipModel "

Exit Select

Case &H5028

s = "PropertyTagThumbnailStripOffsets "

Exit Select

Case &H5029

s = "PropertyTagThumbnailOrientation "

Exit Select

Case &H502A

s = "PropertyTagThumbnailSamplesPerPixel "

Exit Select

Case &H502B

s = "PropertyTagThumbnailRowsPerStrip "

Exit Select

Case &H502C

s = "PropertyTagThumbnailStripBytesCount "

Exit Select

Case &H502D

s = "PropertyTagThumbnailResolutionX "

Exit Select

Case &H502E

s = "PropertyTagThumbnailResolutionY "

Exit Select

Case &H502F

s = "PropertyTagThumbnailPlanarConfig "

Exit Select

Case &H5030

s = "PropertyTagThumbnailResolutionUnit "
Exit Select

Case &H5031

s = "PropertyTagThumbnailTransferFunction "

Exit Select

Case &H5032

s = "PropertyTagThumbnailSoftwareUsed "

Exit Select

Case &H5033

s = "PropertyTagThumbnailDateTime "

Exit Select

Case &H5034

s = "PropertyTagThumbnailArtist "

Exit Select

Case &H5035

s = "PropertyTagThumbnailWhitePoint "

Exit Select

Case &H5036

s = "PropertyTagThumbnailPrimaryChromaticities "

Exit Select

Case &H5037

s = "PropertyTagThumbnailYCbCrCoefficients "

Exit Select

Case &H5038

s = "PropertyTagThumbnailYCbCrSubsampling "

Exit Select

Case &H5039

s = "PropertyTagThumbnailYCbCrPositioning "

Exit Select
Case &H503A

s = "PropertyTagThumbnailRefBlackWhite "

Exit Select

Case &H503B

s = "PropertyTagThumbnailCopyRight "

Exit Select

Case &H5090

s = "PropertyTagLuminanceTable "

Exit Select

Case &H5091

s = "PropertyTagChrominanceTable "

Exit Select

Case &H5100

s = "PropertyTagFrameDelay "

Exit Select

Case &H5101

s = "PropertyTagLoopCount "

Exit Select

Case &H5102

s = "PropertyTagGlobalPalette "

Exit Select

Case &H5103

s = "PropertyTagIndexBackground "

Exit Select

Case &H5104

s = "PropertyTagIndexTransparent "

Exit Select

Case &H5110
s = "PropertyTagPixelUnit "

Exit Select

Case &H5111

s = "PropertyTagPixelPerUnitX "

Exit Select

Case &H5112

s = "PropertyTagPixelPerUnitY "

Exit Select

Case &H5113

s = "PropertyTagPaletteHistogram "

Exit Select

Case &H8298

s = "PropertyTagCopyright "

Exit Select

Case &H829A

s = "PropertyTagExifExposureTime "

Exit Select

Case &H829D

s = "PropertyTagExifFNumber "

Exit Select

Case &H8769

s = "PropertyTagExifIFD "

Exit Select

Case &H8773

s = "PropertyTagICCProfile "

Exit Select

Case &H8822

s = "PropertyTagExifExposureProg "
Exit Select

Case &H8824

s = "PropertyTagExifSpectralSense "

Exit Select

Case &H8825

s = "PropertyTagGpsIFD "

Exit Select

Case &H8827

s = "PropertyTagExifISOSpeed "

Exit Select

Case &H8828

s = "PropertyTagExifOECF "

Exit Select

Case &H9000

s = "PropertyTagExifVer "

Exit Select

Case &H9003

s = "PropertyTagExifDTOrig "

Exit Select

Case &H9004

s = "PropertyTagExifDTDigitized "

Exit Select

Case &H9101

s = "PropertyTagExifCompConfig "

Exit Select

Case &H9102

s = "PropertyTagExifCompBPP "

Exit Select
Case &H9201

s = "PropertyTagExifShutterSpeed "

Exit Select

Case &H9202

s = "PropertyTagExifAperture "

Exit Select

Case &H9203

s = "PropertyTagExifBrightness "

Exit Select

Case &H9204

s = "PropertyTagExifExposureBias "

Exit Select

Case &H9205

s = "PropertyTagExifMaxAperture "

Exit Select

Case &H9206

s = "PropertyTagExifSubjectDist "

Exit Select

Case &H9207

s = "PropertyTagExifMeteringMode "

Exit Select

Case &H9208

s = "PropertyTagExifLightSource "

Exit Select

Case &H9209

s = "PropertyTagExifFlash "

Exit Select

Case &H920A
s = "PropertyTagExifFocalLength "

Exit Select

Case &H927C

s = "PropertyTagExifMakerNote "

Exit Select

Case &H9286

s = "PropertyTagExifUserComment "

Exit Select

Case &H9290

s = "PropertyTagExifDTSubsec "

Exit Select

Case &H9291

s = "PropertyTagExifDTOrigSS "

Exit Select

Case &H9292

s = "PropertyTagExifDTDigSS "

Exit Select

Case &HA000

s = "PropertyTagExifFPXVer "

Exit Select

Case &HA001

s = "PropertyTagExifColorSpace "

Exit Select

Case &HA002

s = "PropertyTagExifPixXDim "

Exit Select

Case &HA003

s = "PropertyTagExifPixYDim "
Exit Select

Case &HA004

s = "PropertyTagExifRelatedWav "

Exit Select

Case &HA005

s = "PropertyTagExifInterop "

Exit Select

Case &HA20B

s = "PropertyTagExifFlashEnergy "

Exit Select

Case &HA20C

s = "PropertyTagExifSpatialFR "

Exit Select

Case &HA20E

s = "PropertyTagExifFocalXRes "

Exit Select

Case &HA20F

s = "PropertyTagExifFocalYRes "

Exit Select

Case &HA210

s = "PropertyTagExifFocalResUnit "

Exit Select

Case &HA214

s = "PropertyTagExifSubjectLoc "

Exit Select

Case &HA215

s = "PropertyTagExifExposureIndex "

Exit Select
Case &HA217

s = "PropertyTagExifSensingMethod "

Exit Select

Case &HA300

s = "PropertyTagExifFileSource "

Exit Select

Case &HA301

s = "PropertyTagExifSceneType "

Exit Select

Case &HA302

s = "PropertyTagExifCfaPattern "

Exit Select

End Select

sb.Append(s & vbCr & vbLf)

Dim t As String = "UnknownType"

Select Case i.Type

Case 1

t = "PropertyTagTypeByte"

Exit Select

Case 2

t = "PropertyTagTypeASCII"

Exit Select

Case 3

t = "PropertyTagTypeShort"

Exit Select

Case 4

t = "PropertyTagTypeLong"

Exit Select
Case 5

t = "PropertyTagTypeRational"

Exit Select

Case 7

t = "PropertyTagTypeUndefined"

Exit Select

Case 9

t = "PropertyTagTypeSLONG"

Exit Select

Case 10

t = "PropertyTagTypeSRational"

Exit Select

End Select

sb.Append(String.Format(vbTab & "Type:{0}" & vbCr & vbLf &


vbTab & "Length:{1}" & vbCr & vbLf & vbTab & "Values:" & vbCr & vbLf & "{2}"
& vbCr & vbLf, t, i.Len, DumpValues(i.Value)))
Next

Me.textBox1.Text = sb.ToString()

End If
textBox1.Visible = True

Label1.Visible = True
button1.Visible = False
End Sub

Private Sub button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles button2.Click
Application.Exit()

End Sub
End Class

IMAGECONVERT.VB
Imports System
Imports System.Drawing
Imports System.Drawing.imaging
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.IO
Imports System.Threading
Public Class imageconvert
Inherits System.Windows.Forms.Form
#Region "Delegates"
Private Delegate Sub ImageInfoDelegate(ByVal thumbnail As Thumbnail,
ByVal targetFile As String, ByVal toSize As System.Drawing.Size)
#End Region
#Region "Fields"
Private _convertThread As Thread = Nothing
Private _imageInfoDelegate As ImageInfoDelegate = Nothing
Private _margin As Integer = 5
Private _converting As Boolean = False
#End Region
#Region "Generated Methods"
Public Sub New()
Me.InitializeComponent()
_imageInfoDelegate = New ImageInfoDelegate(AddressOf
DisplayImageInfo)
For Each imageFormat As TargetImageFormat In
[Enum].GetValues(GetType(TargetImageFormat))
Me.comboBoxTargetFormat.Items.Add(imageFormat)
Next
Me.comboBoxTargetFormat.SelectedItem = TargetImageFormat.JPEG
Me.openFileDialog.Filter = "Bitmap Files (*.bmp)|*.bmp|JPEG
(*.jpg,*jpeg,*.jpe,*.jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|GIF (*.gif)|*.gif|Icon
(*.ico)|*.ico|Enhanced Meta File (*.emf)|*.emf|TIFF (*.tif,*.tiff)|
*.tif;*.tiff|PNG (*.png)|*.png|All Image Files|
*.bmp;*.jpg;*.jpeg;*.jpe;*.jfif;*.gif;*.tif;*.tiff;*.png;*.ico"
Me.openFileDialog.FilterIndex = 8
Me.EnableControls()
End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)


If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

#Region "Windows Form Designer generated code"


Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager =
New System.ComponentModel.ComponentResourceManager(GetType(imageconvert))
Me.statusBar1 = New System.Windows.Forms.StatusBar
Me.statusBarPanelFile = New System.Windows.Forms.StatusBarPanel
Me.statusBarPanelOriginalSize = New
System.Windows.Forms.StatusBarPanel
Me.statusBarPanelNewSize = New System.Windows.Forms.StatusBarPanel
Me.statusBarPanelRemainder = New System.Windows.Forms.StatusBarPanel
Me.radioButtonSpecified = New System.Windows.Forms.RadioButton
Me.radioButtonMaximum = New System.Windows.Forms.RadioButton
Me.groupBoxTargetSize = New System.Windows.Forms.GroupBox
Me.numericUpDownPercentage = New System.Windows.Forms.NumericUpDown
Me.numericUpDownMaximum = New System.Windows.Forms.NumericUpDown
Me.numericUpDownSpecifiedHeight = New
System.Windows.Forms.NumericUpDown
Me.labelPercentage = New System.Windows.Forms.Label
Me.radioButtonPercentage = New System.Windows.Forms.RadioButton
Me.labelTimes = New System.Windows.Forms.Label
Me.numericUpDownSpecifiedWidth = New
System.Windows.Forms.NumericUpDown
Me.labelTargetPath = New System.Windows.Forms.Label
Me.buttonOpen = New System.Windows.Forms.Button
Me.buttonBrowseTargetPath = New System.Windows.Forms.Button
Me.labelTargetPathValue = New System.Windows.Forms.Label
Me.panelThumbnails = New System.Windows.Forms.Panel
Me.buttonConvert = New System.Windows.Forms.Button
Me.buttonClose = New System.Windows.Forms.Button
Me.folderBrowserDialogTargetPath = New
System.Windows.Forms.FolderBrowserDialog
Me.groupBoxOnConvert = New System.Windows.Forms.GroupBox
Me.textBoxPrefix = New System.Windows.Forms.TextBox
Me.radioButtonUsePrefix = New System.Windows.Forms.RadioButton
Me.radioButtonOverwrite = New System.Windows.Forms.RadioButton
Me.openFileDialog = New System.Windows.Forms.OpenFileDialog
Me.labelSourceImages = New System.Windows.Forms.Label
Me.comboBoxTargetFormat = New System.Windows.Forms.ComboBox
Me.labelTargetFormat = New System.Windows.Forms.Label
Me.Panel2 = New System.Windows.Forms.Panel
Me.Label2 = New System.Windows.Forms.Label
Me.picSrc1 = New System.Windows.Forms.PictureBox
Me.picSrc2 = New System.Windows.Forms.PictureBox
Me.tmrDisplayFrame = New System.Windows.Forms.Timer(Me.components)
Me.picResult = New System.Windows.Forms.PictureBox
Me.Panel1 = New System.Windows.Forms.Panel
CType(Me.statusBarPanelFile,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.statusBarPanelOriginalSize,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.statusBarPanelNewSize,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.statusBarPanelRemainder,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.groupBoxTargetSize.SuspendLayout()
CType(Me.numericUpDownPercentage,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.numericUpDownMaximum,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.numericUpDownSpecifiedHeight,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.numericUpDownSpecifiedWidth,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.groupBoxOnConvert.SuspendLayout()
Me.Panel2.SuspendLayout()
CType(Me.picSrc1,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.picSrc2,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.picResult,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
Me.statusBar1.Location = New System.Drawing.Point(0, 569)
Me.statusBar1.Name = "statusBar1"
Me.statusBar1.Panels.AddRange(New
System.Windows.Forms.StatusBarPanel() {Me.statusBarPanelFile,
Me.statusBarPanelOriginalSize, Me.statusBarPanelNewSize,
Me.statusBarPanelRemainder})
Me.statusBar1.ShowPanels = True
Me.statusBar1.Size = New System.Drawing.Size(805, 10)
Me.statusBar1.TabIndex = 4
Me.statusBar1.Text = "statusBar"
Me.statusBarPanelFile.AutoSize =
System.Windows.Forms.StatusBarPanelAutoSize.Contents
Me.statusBarPanelFile.Name = "statusBarPanelFile"
Me.statusBarPanelFile.Width = 10
Me.statusBarPanelOriginalSize.Name = "statusBarPanelOriginalSize"
Me.statusBarPanelOriginalSize.Width = 150
Me.statusBarPanelNewSize.Name = "statusBarPanelNewSize"
Me.statusBarPanelNewSize.Width = 150
Me.statusBarPanelRemainder.AutoSize =
System.Windows.Forms.StatusBarPanelAutoSize.Spring
Me.statusBarPanelRemainder.Name = "statusBarPanelRemainder"
Me.statusBarPanelRemainder.Width = 478
Me.radioButtonSpecified.Location = New System.Drawing.Point(8, 16)
Me.radioButtonSpecified.Name = "radioButtonSpecified"
Me.radioButtonSpecified.Size = New System.Drawing.Size(80, 24)
Me.radioButtonSpecified.TabIndex = 5
Me.radioButtonSpecified.Text = "Specified:"
Me.radioButtonMaximum.Checked = True
Me.radioButtonMaximum.Location = New System.Drawing.Point(8, 40)
Me.radioButtonMaximum.Name = "radioButtonMaximum"
Me.radioButtonMaximum.Size = New System.Drawing.Size(80, 24)
Me.radioButtonMaximum.TabIndex = 6
Me.radioButtonMaximum.TabStop = True
Me.radioButtonMaximum.Text = "Maximum:"
Me.groupBoxTargetSize.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.groupBoxTargetSize.Controls.Add(Me.numericUpDownPercentage)
Me.groupBoxTargetSize.Controls.Add(Me.numericUpDownMaximum)
Me.groupBoxTargetSize.Controls.Add(Me.numericUpDownSpecifiedHeight)
Me.groupBoxTargetSize.Controls.Add(Me.labelPercentage)
Me.groupBoxTargetSize.Controls.Add(Me.radioButtonPercentage)
Me.groupBoxTargetSize.Controls.Add(Me.labelTimes)
Me.groupBoxTargetSize.Controls.Add(Me.radioButtonSpecified)
Me.groupBoxTargetSize.Controls.Add(Me.radioButtonMaximum)
Me.groupBoxTargetSize.Controls.Add(Me.numericUpDownSpecifiedWidth)
Me.groupBoxTargetSize.Location = New System.Drawing.Point(571, 205)
Me.groupBoxTargetSize.Name = "groupBoxTargetSize"
Me.groupBoxTargetSize.Size = New System.Drawing.Size(224, 100)
Me.groupBoxTargetSize.TabIndex = 7
Me.groupBoxTargetSize.TabStop = False
Me.groupBoxTargetSize.Text = "Target Size"
Me.numericUpDownPercentage.Location = New System.Drawing.Point(88,
68)
Me.numericUpDownPercentage.Maximum = New Decimal(New Integer() {500,
0, 0, 0})
Me.numericUpDownPercentage.Name = "numericUpDownPercentage"
Me.numericUpDownPercentage.Size = New System.Drawing.Size(56, 20)
Me.numericUpDownPercentage.TabIndex = 20
Me.numericUpDownPercentage.Value = New Decimal(New Integer() {100,
0, 0, 0})
Me.numericUpDownMaximum.Location = New System.Drawing.Point(88, 44)
Me.numericUpDownMaximum.Maximum = New Decimal(New Integer() {100000,
0, 0, 0})
Me.numericUpDownMaximum.Name = "numericUpDownMaximum"
Me.numericUpDownMaximum.Size = New System.Drawing.Size(56, 20)
Me.numericUpDownMaximum.TabIndex = 19
Me.numericUpDownMaximum.Value = New Decimal(New Integer() {768, 0,
0, 0})
Me.numericUpDownSpecifiedHeight.Location = New
System.Drawing.Point(160, 20)
Me.numericUpDownSpecifiedHeight.Maximum = New Decimal(New Integer()
{100000, 0, 0, 0})
Me.numericUpDownSpecifiedHeight.Name =
"numericUpDownSpecifiedHeight"
Me.numericUpDownSpecifiedHeight.Size = New System.Drawing.Size(56,
20)
Me.numericUpDownSpecifiedHeight.TabIndex = 18
Me.numericUpDownSpecifiedHeight.Value = New Decimal(New Integer()
{600, 0, 0, 0})
Me.labelPercentage.Font = New System.Drawing.Font("Microsoft Sans Serif",
8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
CType(0, Byte))
Me.labelPercentage.Location = New System.Drawing.Point(150, 65)
Me.labelPercentage.Name = "labelPercentage"
Me.labelPercentage.Size = New System.Drawing.Size(8, 23)
Me.labelPercentage.TabIndex = 13
Me.labelPercentage.Text = "%"
Me.labelPercentage.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
Me.radioButtonPercentage.Location = New System.Drawing.Point(8, 64)
Me.radioButtonPercentage.Name = "radioButtonPercentage"
Me.radioButtonPercentage.Size = New System.Drawing.Size(83, 24)
Me.radioButtonPercentage.TabIndex = 11
Me.radioButtonPercentage.Text = "Percentage:"
Me.labelTimes.Font = New System.Drawing.Font("Symbol", 8.25!,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0,
Byte))
Me.labelTimes.Location = New System.Drawing.Point(148, 18)
Me.labelTimes.Name = "labelTimes"
Me.labelTimes.Size = New System.Drawing.Size(8, 23)
Me.labelTimes.TabIndex = 9
Me.labelTimes.Text = "´"
Me.labelTimes.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter
Me.numericUpDownSpecifiedWidth.Location = New
System.Drawing.Point(88, 20)
Me.numericUpDownSpecifiedWidth.Maximum = New Decimal(New Integer()
{100000, 0, 0, 0})
Me.numericUpDownSpecifiedWidth.Name = "numericUpDownSpecifiedWidth"
Me.numericUpDownSpecifiedWidth.Size = New System.Drawing.Size(56,
20)
Me.numericUpDownSpecifiedWidth.TabIndex = 17
Me.numericUpDownSpecifiedWidth.Value = New Decimal(New Integer()
{800, 0, 0, 0})
Me.labelTargetPath.Location = New System.Drawing.Point(351, 148)
Me.labelTargetPath.Name = "labelTargetPath"
Me.labelTargetPath.Size = New System.Drawing.Size(72, 23)
Me.labelTargetPath.TabIndex = 10
Me.labelTargetPath.Text = "Target path:"
Me.labelTargetPath.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
Me.buttonOpen.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
Me.buttonOpen.DialogResult =
System.Windows.Forms.DialogResult.Cancel
Me.buttonOpen.Location = New System.Drawing.Point(308, 147)
Me.buttonOpen.Name = "buttonOpen"
Me.buttonOpen.Size = New System.Drawing.Size(41, 23)
Me.buttonOpen.TabIndex = 11
Me.buttonOpen.Text = "Open..."
Me.buttonOpen.UseVisualStyleBackColor = False
Me.buttonBrowseTargetPath.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.buttonBrowseTargetPath.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
Me.buttonBrowseTargetPath.DialogResult =
System.Windows.Forms.DialogResult.Cancel
Me.buttonBrowseTargetPath.Location = New System.Drawing.Point(739,
151)
Me.buttonBrowseTargetPath.Name = "buttonBrowseTargetPath"
Me.buttonBrowseTargetPath.Size = New System.Drawing.Size(60, 23)
Me.buttonBrowseTargetPath.TabIndex = 13
Me.buttonBrowseTargetPath.Text = "Browse..."
Me.buttonBrowseTargetPath.UseVisualStyleBackColor = False
Me.labelTargetPathValue.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.labelTargetPathValue.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.labelTargetPathValue.Location = New System.Drawing.Point(429,
147)
Me.labelTargetPathValue.Name = "labelTargetPathValue"
Me.labelTargetPathValue.Size = New System.Drawing.Size(297, 24)
Me.labelTargetPathValue.TabIndex = 12
Me.labelTargetPathValue.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
Me.panelThumbnails.Anchor =
CType((((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.panelThumbnails.AutoScroll = True
Me.panelThumbnails.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.panelThumbnails.BorderStyle =
System.Windows.Forms.BorderStyle.Fixed3D
Me.panelThumbnails.Location = New System.Drawing.Point(225, 177)
Me.panelThumbnails.Name = "panelThumbnails"
Me.panelThumbnails.Size = New System.Drawing.Size(340, 374)
Me.panelThumbnails.TabIndex = 14
Me.buttonConvert.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.buttonConvert.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.buttonConvert.Location = New System.Drawing.Point(603, 498)
Me.buttonConvert.Name = "buttonConvert"
Me.buttonConvert.Size = New System.Drawing.Size(75, 23)
Me.buttonConvert.TabIndex = 15
Me.buttonConvert.Text = "Convert"
Me.buttonConvert.UseVisualStyleBackColor = False
Me.buttonClose.Anchor = CType((System.Windows.Forms.AnchorStyles.Top
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.buttonClose.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.buttonClose.DialogResult =
System.Windows.Forms.DialogResult.Cancel
Me.buttonClose.Location = New System.Drawing.Point(683, 498)
Me.buttonClose.Name = "buttonClose"
Me.buttonClose.Size = New System.Drawing.Size(75, 23)
Me.buttonClose.TabIndex = 16
Me.buttonClose.Text = "Close"
Me.buttonClose.UseVisualStyleBackColor = False
Me.folderBrowserDialogTargetPath.Description = "Select the folder to
which the converted images will be written."
Me.groupBoxOnConvert.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.groupBoxOnConvert.Controls.Add(Me.textBoxPrefix)
Me.groupBoxOnConvert.Controls.Add(Me.radioButtonUsePrefix)
Me.groupBoxOnConvert.Controls.Add(Me.radioButtonOverwrite)
Me.groupBoxOnConvert.Location = New System.Drawing.Point(571, 342)
Me.groupBoxOnConvert.Name = "groupBoxOnConvert"
Me.groupBoxOnConvert.Size = New System.Drawing.Size(224, 88)
Me.groupBoxOnConvert.TabIndex = 17
Me.groupBoxOnConvert.TabStop = False
Me.groupBoxOnConvert.Text = "On Convert"
Me.textBoxPrefix.Location = New System.Drawing.Point(88, 51)
Me.textBoxPrefix.Name = "textBoxPrefix"
Me.textBoxPrefix.Size = New System.Drawing.Size(128, 20)
Me.textBoxPrefix.TabIndex = 2
Me.textBoxPrefix.Text = "image_"
Me.radioButtonUsePrefix.Checked = True
Me.radioButtonUsePrefix.Location = New System.Drawing.Point(8, 48)
Me.radioButtonUsePrefix.Name = "radioButtonUsePrefix"
Me.radioButtonUsePrefix.Size = New System.Drawing.Size(80, 24)
Me.radioButtonUsePrefix.TabIndex = 1
Me.radioButtonUsePrefix.TabStop = True
Me.radioButtonUsePrefix.Text = "Use prefix:"
Me.radioButtonOverwrite.Location = New System.Drawing.Point(8, 24)
Me.radioButtonOverwrite.Name = "radioButtonOverwrite"
Me.radioButtonOverwrite.Size = New System.Drawing.Size(200, 24)
Me.radioButtonOverwrite.TabIndex = 0
Me.radioButtonOverwrite.Text = "Same name, overwrite existing files"
Me.openFileDialog.FilterIndex = 7
Me.openFileDialog.Multiselect = True
Me.labelSourceImages.Location = New System.Drawing.Point(221, 147)
Me.labelSourceImages.Name = "labelSourceImages"
Me.labelSourceImages.Size = New System.Drawing.Size(88, 23)
Me.labelSourceImages.TabIndex = 19
Me.labelSourceImages.Text = "Source Images:"
Me.labelSourceImages.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
Me.comboBoxTargetFormat.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.comboBoxTargetFormat.DropDownStyle =
System.Windows.Forms.ComboBoxStyle.DropDownList
Me.comboBoxTargetFormat.Location = New System.Drawing.Point(667,
440)
Me.comboBoxTargetFormat.Name = "comboBoxTargetFormat"
Me.comboBoxTargetFormat.Size = New System.Drawing.Size(128, 21)
Me.comboBoxTargetFormat.TabIndex = 20
Me.labelTargetFormat.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.labelTargetFormat.Location = New System.Drawing.Point(571, 438)
Me.labelTargetFormat.Name = "labelTargetFormat"
Me.labelTargetFormat.Size = New System.Drawing.Size(88, 23)
Me.labelTargetFormat.TabIndex = 21
Me.labelTargetFormat.Text = "Target Format:"
Me.labelTargetFormat.TextAlign =
System.Drawing.ContentAlignment.MiddleLeft
Me.Panel2.BackColor = System.Drawing.Color.FromArgb(CType(CType(255,
Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(128, Byte),
Integer))
Me.Panel2.Controls.Add(Me.Label2)
Me.Panel2.Controls.Add(Me.picSrc1)
Me.Panel2.Controls.Add(Me.picSrc2)
Me.Panel2.Location = New System.Drawing.Point(-3, 138)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(227, 446)
Me.Panel2.TabIndex = 29
Me.Label2.AutoSize = True
Me.Label2.ForeColor = System.Drawing.Color.Navy
Me.Label2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label2.Location = New System.Drawing.Point(-3, 39)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(189, 169)
Me.Label2.TabIndex = 25
Me.Label2.Text = resources.GetString("Label2.Text")
Me.picSrc1.Image = CType(resources.GetObject("picSrc1.Image"),
System.Drawing.Image)
Me.picSrc1.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picSrc1.Location = New System.Drawing.Point(65, 236)
Me.picSrc1.Name = "picSrc1"
Me.picSrc1.Size = New System.Drawing.Size(100, 50)
Me.picSrc1.TabIndex = 26
Me.picSrc1.TabStop = False
Me.picSrc1.Visible = False
Me.picSrc2.Image = CType(resources.GetObject("picSrc2.Image"),
System.Drawing.Image)
Me.picSrc2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picSrc2.Location = New System.Drawing.Point(65, 307)
Me.picSrc2.Name = "picSrc2"
Me.picSrc2.Size = New System.Drawing.Size(100, 50)
Me.picSrc2.TabIndex = 27
Me.picSrc2.TabStop = False
Me.picSrc2.Visible = False
Me.tmrDisplayFrame.Enabled = True
Me.tmrDisplayFrame.Interval = 50
Me.picResult.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.picResult.Location = New System.Drawing.Point(228, 0)
Me.picResult.Name = "picResult"
Me.picResult.Size = New System.Drawing.Size(646, 147)
Me.picResult.TabIndex = 20
Me.picResult.TabStop = False
Me.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(0,
Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(192, Byte),
Integer))
Me.Panel1.BackgroundImage =
Global.DCC_final.My.Resources.Resources.untitled21
Me.Panel1.BackgroundImageLayout =
System.Windows.Forms.ImageLayout.Stretch
Me.Panel1.Controls.Add(Me.picResult)
Me.Panel1.ForeColor = System.Drawing.Color.White
Me.Panel1.Location = New System.Drawing.Point(-3, -5)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(810, 147)
Me.Panel1.TabIndex = 25
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte),
Integer), CType(CType(224, Byte), Integer), CType(CType(192, Byte),
Integer))
Me.ClientSize = New System.Drawing.Size(805, 579)
Me.Controls.Add(Me.Panel2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.labelTargetFormat)
Me.Controls.Add(Me.comboBoxTargetFormat)
Me.Controls.Add(Me.labelSourceImages)
Me.Controls.Add(Me.groupBoxOnConvert)
Me.Controls.Add(Me.buttonClose)
Me.Controls.Add(Me.buttonConvert)
Me.Controls.Add(Me.buttonBrowseTargetPath)
Me.Controls.Add(Me.buttonOpen)
Me.Controls.Add(Me.labelTargetPath)
Me.Controls.Add(Me.groupBoxTargetSize)
Me.Controls.Add(Me.statusBar1)
Me.Controls.Add(Me.panelThumbnails)
Me.Controls.Add(Me.labelTargetPathValue)
Me.Name = "imageconvert"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Image Resizer"
CType(Me.statusBarPanelFile,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusBarPanelOriginalSize,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusBarPanelNewSize,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusBarPanelRemainder,
System.ComponentModel.ISupportInitialize).EndInit()
Me.groupBoxTargetSize.ResumeLayout(False)
CType(Me.numericUpDownPercentage,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.numericUpDownMaximum,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.numericUpDownSpecifiedHeight,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.numericUpDownSpecifiedWidth,
System.ComponentModel.ISupportInitialize).EndInit()
Me.groupBoxOnConvert.ResumeLayout(False)
Me.groupBoxOnConvert.PerformLayout()
Me.Panel2.ResumeLayout(False)
Me.Panel2.PerformLayout()
CType(Me.picSrc1,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.picSrc2,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.picResult,
System.ComponentModel.ISupportInitialize).EndInit()
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)

End Sub
#End Region
<STAThread()> _
Private Shared Sub Main()
Application.Run(New imageconvert())
End Sub

#End Region

#Region "Methods"

Private Sub EnableControls()


Me.buttonConvert.Enabled = Not _converting AndAlso
Me.panelThumbnails.Controls.Count > 0 AndAlso
Me.labelTargetPathValue.Text.Trim() <> ""
Me.buttonBrowseTargetPath.Enabled = Not _converting
Me.buttonOpen.Enabled = Not _converting
Me.groupBoxOnConvert.Enabled = Not _converting
Me.groupBoxTargetSize.Enabled = Not _converting
Me.comboBoxTargetFormat.Enabled = Not _converting
End Sub
Private Function GetExtension() As String
Select Case DirectCast(Me.comboBoxTargetFormat.SelectedItem,
TargetImageFormat)
Case TargetImageFormat.Bitmap
If True Then
Return ".bmp"
End If
Case TargetImageFormat.JPEG
If True Then
Return ".jpg"
End If
Case TargetImageFormat.GIF

If True Then
Return ".gif"
End If
Case TargetImageFormat.TIFF
If True Then
Return ".tif"
End If
Case TargetImageFormat.PNG
If True Then
Return ".png"
End If
Case TargetImageFormat.Icon
If True Then
Return ".ico"
End If
Case TargetImageFormat.EnhancedMetaFile
If True Then
Return ".emf"
End If
End Select
Return ".jpg"
End Function
Private Function GetImageFormat() As System.Drawing.Imaging.ImageFormat
Select Case DirectCast(Me.comboBoxTargetFormat.SelectedItem,
TargetImageFormat)
Case TargetImageFormat.Bitmap
If True Then
Return System.Drawing.Imaging.ImageFormat.Bmp
End If
Case TargetImageFormat.JPEG
If True Then
Return System.Drawing.Imaging.ImageFormat.Jpeg
End If
Case TargetImageFormat.GIF
If True Then
Return System.Drawing.Imaging.ImageFormat.Gif
End If
Case TargetImageFormat.TIFF
If True Then
Return System.Drawing.Imaging.ImageFormat.Tiff
End If
Case TargetImageFormat.PNG
If True Then
Return System.Drawing.Imaging.ImageFormat.Png
End If
Case TargetImageFormat.Icon
If True Then
Return System.Drawing.Imaging.ImageFormat.Icon
End If
Case TargetImageFormat.EnhancedMetaFile
If True Then
Return System.Drawing.Imaging.ImageFormat.Emf
End If
End Select
Return System.Drawing.Imaging.ImageFormat.Jpeg
End Function
Private Function DetermineTargetSize(ByVal image As
System.Drawing.Image) As System.Drawing.Size
Dim width As Integer = image.Width
Dim height As Integer = image.Height
If Me.radioButtonSpecified.Checked Then
If image.Width > image.Height Then
width = CInt(Me.numericUpDownSpecifiedWidth.Value)
height = CInt(Me.numericUpDownSpecifiedHeight.Value)
Else
width = CInt(Me.numericUpDownSpecifiedHeight.Value)
height = CInt(Me.numericUpDownSpecifiedWidth.Value)
End If
End If
If Me.radioButtonPercentage.Checked Then
width = CInt((image.Width * Me.numericUpDownPercentage.Value /
100))
height = CInt((image.Height * Me.numericUpDownPercentage.Value /
100))
End If
If Me.radioButtonMaximum.Checked Then
If image.Width > Me.numericUpDownMaximum.Value OrElse
image.Height > Me.numericUpDownMaximum.Value Then
If image.Width > image.Height Then
width = CInt(Me.numericUpDownMaximum.Value)
height = CInt((image.Height *
Me.numericUpDownMaximum.Value / image.Width))
Else
width = CInt((image.Width *
Me.numericUpDownMaximum.Value / image.Height))
height = CInt(Me.numericUpDownMaximum.Value)
End If
End If
End If
Return New Size(width, height)
End Function
Private Sub DisplayImageInfo(ByVal thumbnail As Thumbnail, ByVal
targetFile As String, ByVal toSize As System.Drawing.Size)
Me.statusBarPanelFile.Text = targetFile
Me.statusBarPanelOriginalSize.Text = String.Format("original size:
{0} x {1}", thumbnail.Image.Size.Width, thumbnail.Image.Size.Height)
Me.statusBarPanelNewSize.Text = String.Format("converted to: {0} x
{1}", toSize.Width, toSize.Height)
thumbnail.Handled = True
End Sub
Private Sub DisplayThumbnails()
While Me.panelThumbnails.Controls.Count > 0
Dim thumbnail As Thumbnail =
TryCast(Me.panelThumbnails.Controls(0), Thumbnail)
thumbnail.Dispose()
Me.panelThumbnails.Controls.Remove(thumbnail)
End While
Dim numberHorizontal As Integer = -1
For Each file As String In Me.openFileDialog.FileNames
Dim thumbnail As Thumbnail = Nothing
Try
thumbnail = New Thumbnail(file)
Catch generatedExceptionName As System.OutOfMemoryException
thumbnail = Nothing
Continue For
End Try
If numberHorizontal < 0 Then

numberHorizontal = CInt((Me.panelThumbnails.Width /
thumbnail.Width))
End If
thumbnail.Left = _margin + (thumbnail.Width + _margin) *
(Me.panelThumbnails.Controls.Count Mod numberHorizontal)
thumbnail.Top = _margin + (thumbnail.Height + _margin) *
(Me.panelThumbnails.Controls.Count / numberHorizontal)
Me.panelThumbnails.Controls.Add(thumbnail)
Next
End Sub
>
Private Sub ConvertImageFiles()

_converting = True
Me.EnableControls()
Try
Dim seq As Integer = 1
For Each thumbnail As Thumbnail In Me.panelThumbnails.Controls
thumbnail.Handled = False
Next
Dim extension As String = GetExtension()
Dim targetImageFormat As System.Drawing.Imaging.ImageFormat =
GetImageFormat()

For Each thumbnail As Thumbnail In Me.panelThumbnails.Controls


Dim fileName As String =
Path.GetFileName(thumbnail.FilePath)
Dim targetFileName As String

If Me.radioButtonUsePrefix.Checked Then
targetFileName = (Me.labelTargetPathValue.Text & "\") +
Me.textBoxPrefix.Text + seq.ToString("0000") + extension
While File.Exists(targetFileName)
seq += 1
targetFileName = (Me.labelTargetPathValue.Text &
"\") + Me.textBoxPrefix.Text + seq.ToString("0000") + extension
End While
Else
targetFileName = (Me.labelTargetPathValue.Text & "\") +
Path.GetFileNameWithoutExtension(fileName) + extension
End If
Try

Dim targetSize As System.Drawing.Size =


Me.DetermineTargetSize(thumbnail.Image)
Dim targetImage As System.Drawing.Image = Nothing

Try
targetImage = New Bitmap(thumbnail.Image,
targetSize)
targetImage.Save(targetFileName, targetImageFormat)
Me.Invoke(_imageInfoDelegate, New Object()
{thumbnail, targetFileName, targetSize})
targetImage.Dispose()
Catch e As System.Threading.ThreadAbortException
Throw e
Catch
End Try
Catch e As System.Threading.ThreadAbortException
Throw e
Catch
End Try
Next
Catch
Finally
Me.Cursor = Cursors.[Default]
_converting = False
Me.EnableControls()
End Try
End Sub
#End Region
#Region "Event Handlers"

#Region ". Buttons"


Private Sub buttonOpen_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles buttonOpen.Click
If Me.openFileDialog.ShowDialog().Equals(DialogResult.OK) Then
If Me.labelTargetPathValue.Text.Trim().Equals("") Then
Me.labelTargetPathValue.Text =
Path.GetDirectoryName(Me.openFileDialog.FileNames(0))
End If
Me.DisplayThumbnails()
End If
Me.EnableControls()
End Sub
Private Sub buttonBrowseTargetPath_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles buttonBrowseTargetPath.Click
Me.folderBrowserDialogTargetPath.SelectedPath =
Me.labelTargetPathValue.Text
If
Me.folderBrowserDialogTargetPath.ShowDialog().Equals(DialogResult.OK) Then
Me.labelTargetPathValue.Text =
Me.folderBrowserDialogTargetPath.SelectedPath
Me.EnableControls()
End If
End Sub
Private Sub buttonConvert_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles buttonConvert.Click
ConvertImageFiles()
End Sub
Private Sub buttonClose_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles buttonClose.Click
If _converting Then
_convertThread.Abort()
Else
Me.Close()
End If
End Sub
#End Region

#Region ". Form"


Private Sub FormResizer_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs)
e.Cancel = _converting
End Sub
#End Region

#Region ". Numeric Up Downs"

Private m_Alpha As Single = 0 Private m_DAlpha As Single = 0.05

Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

picResult.Image = bm
picResult.Refresh()

m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

Private Sub numericUpDownSpecifiedWidth_ValueChanged(ByVal sender As


Object, ByVal e As System.EventArgs) Handles
numericUpDownSpecifiedWidth.ValueChanged
Me.radioButtonSpecified.Checked = True
End Sub
Private Sub numericUpDownSpecifiedHeight_ValueChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
numericUpDownSpecifiedHeight.ValueChanged
Me.radioButtonSpecified.Checked = True
End Sub
Private Sub numericUpDownMaximum_ValueChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles numericUpDownMaximum.ValueChanged
Me.radioButtonMaximum.Checked = True
End Sub
Private Sub numericUpDownPercentage_ValueChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles numericUpDownPercentage.ValueChanged
Me.radioButtonPercentage.Checked = True
End Sub
#End Region

#Region ". Radio Buttons"


Private Sub radioButtonOverwrite_CheckedChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles radioButtonOverwrite.CheckedChanged
Me.EnableControls()
End Sub
Private Sub radioButtonUsePrefix_CheckedChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles radioButtonUsePrefix.CheckedChanged
Me.EnableControls()
End Sub
#End Region

#Region ". Text Boxes"


Private Sub textBoxPrefix_TextChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles textBoxPrefix.TextChanged
Me.radioButtonUsePrefix.Checked = True
Me.EnableControls()
End Sub
#End Region

#End Region
End Class
#Region "Enums"
Public Enum TargetImageFormat
Bitmap
JPEG
GIF
TIFF
PNG
Icon
EnhancedMetaFile
End Enum
#End Region
IMAGEFORMAT.VB

Public Class imageformat

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub

Private Sub JPGToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles JPGToolStripMenuItem.Click
On Error Resume Next
With OpenFileDialog1
.CheckFileExists = True
.FileName = "*.JPG"
.AddExtension = True
.DefaultExt = "*.JPG"
.ShowDialog()
PictureBox1.Image = New System.Drawing.Bitmap(.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End With
End Sub

Private Sub GIFToolStripMenuItem2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles GIFToolStripMenuItem2.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "JPG", "GIF")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Gif)
Dim answer As MsgBoxResult
answer = MsgBox("Save in GIF in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub BMPToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles BMPToolStripMenuItem.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "JPG", "BMP")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp)
Dim answer As MsgBoxResult
answer = MsgBox("Save in BMP in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub ToujoursVisibleToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ToujoursVisibleToolStripMenuItem.Click
On Error Resume Next
With OpenFileDialog1
.CheckFileExists = True
.FileName = "*.ICO"
.AddExtension = True
.DefaultExt = "*.ICO"
.ShowDialog()
PictureBox1.Image = New System.Drawing.Bitmap(.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End With
End Sub

Private Sub GIFToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles GIFToolStripMenuItem.Click
On Error Resume Next
With OpenFileDialog1
.CheckFileExists = True
.FileName = "*.GIF"
.AddExtension = True
.DefaultExt = "*.GIF"
.ShowDialog()
PictureBox1.Image = New System.Drawing.Bitmap(.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End With
End Sub

Private Sub BMPToolStripMenuItem1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles BMPToolStripMenuItem1.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "GIF", "BMP")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp)
Dim answer As MsgBoxResult
answer = MsgBox("Save in BMP in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub JPGToolStripMenuItem2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles JPGToolStripMenuItem2.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "GIF", "JPG")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim answer As MsgBoxResult
answer = MsgBox("Save in JPG in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub ICOToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ICOToolStripMenuItem.Click
On Error Resume Next
With OpenFileDialog1
.CheckFileExists = True
.FileName = "*.BMP"
.AddExtension = True
.DefaultExt = "*.BMP"
.ShowDialog()
PictureBox1.Image = New System.Drawing.Bitmap(.FileName)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End With
End Sub

Private Sub JPGToolStripMenuItem1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles JPGToolStripMenuItem1.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "BMP", "JPG")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim answer As MsgBoxResult
answer = MsgBox("Save in JPG in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub GIFToolStripMenuItem1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles GIFToolStripMenuItem1.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "BMP", "GIF")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Gif)
Dim answer As MsgBoxResult
answer = MsgBox("Save in GIF in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub ToujoursVisibleToolStripMenuItem1_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ToujoursVisibleToolStripMenuItem1.Click

Me.TopMost = Not (Me.TopMost)

End Sub

Private Sub SauverJPGToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
SauverJPGToolStripMenuItem.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "ICO", "JPG")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim answer As MsgBoxResult
answer = MsgBox("Save in JPG in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub SauverGIFToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
SauverGIFToolStripMenuItem.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "ICO", "GIF")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Gif)
Dim answer As MsgBoxResult
answer = MsgBox("Save in GIF in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub

Private Sub SauverBMPToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
SauverBMPToolStripMenuItem.Click
On Error Resume Next
Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
Dim tmp As String = OpenFileDialog1.FileName()
If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
My.Computer.Audio.Play("C:\Windows\Media\ringin.wav")
MsgBox("Open a picture!")
Exit Sub
End If
tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "ICO", "BMP")
d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp)
Dim answer As MsgBoxResult
answer = MsgBox("Save in BMP in the file of origin." & vbNewLine &
"You finished?", MsgBoxStyle.YesNo)
If answer = MsgBoxResult.Yes Then
MsgBox("See you soon")
End
End If

End Sub
End Class
ALAA_IMAGE.VB

Option Strict Off


Option Explicit On
Module alaa_image
Public Structure bits_array
<VBFixedArray(7)> Dim bits() As Boolean

'UPGRADE_TODO: "Initialize" must be called to initialize instances


of this structure. Click for more: 'ms-
help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1026"'
Public Sub Initialize()
ReDim bits(7)
End Sub
End Structure
Dim p10 As Object
Dim p20 As bits_array
Public Function power(ByRef x As Byte, ByRef y As Boolean) As Byte
Dim temp As Byte
If y Then
temp = 1
Else
temp = 0
End If
power = x ^ temp ' where y is the power factor
End Function
Public Sub bits_to_byte(ByRef b As Byte, ByRef bits As bits_array)
Dim i As Object
b = 0
For i = 0 To 7
If bits.bits(i) Then
b = b + (2 ^ i)
End If
Next i
End Sub
Public Sub byte_to_bits(ByVal b As Byte, ByRef bits As bits_array)
Dim t As Object
Dim i As Byte
Dim f As Short
Dim f1 As Short
f1 = b Mod 2
If f1 = 0 Then
bits.bits(0) = False
Else
b = b - 1 'b is odd so i must subtract 1 from it
bits.bits(0) = True
End If
Dim j As Short
j = 7
Do While j > 0
t = (2 ^ j)
f = b - t
If (f >= 0) Then
bits.bits(j) = True
b = b - t ' because i took bigest number that fits
'MsgBox bits.bits(j)
Else
bits.bits(j) = False ' i didn,t take the number
End If
j = j - 1
Loop
'to be sure that the bitch 0 in cycle is done
If f1 = 0 Then
bits.bits(0) = False
Else
bits.bits(0) = True
End If
End Sub

Public Sub insert_useless_bit_in_byte(ByRef b As Byte, ByRef va As


Boolean) ' this version will set/ lowest order bit
Dim barsk As bits_array
Call byte_to_bits(b, barsk)
barsk.bits(0) = va
Call bits_to_byte(b, barsk)
End Sub
Public Sub get_useless_bit_in_byte(ByRef b As Byte, ByRef va As Boolean)
' this version will /get lowest order bit
Dim barsk As bits_array
Call byte_to_bits(b, barsk)
va = barsk.bits(0)
End Sub
Public Sub enc_str_do(ByRef tx As String, ByRef PW As String, ByRef FI
As String)
Dim t As String
Dim kl As Short
Dim j As Short
Dim i As Short
Dim i1 As Short
t = StrReverse(tx)
Dim temp As String
Dim l As Integer
Dim A() As Short
Call inalize_pd(l, PW, A)

kl = Len(tx)
FileOpen(12, FI, OpenMode.Random)
FilePut(12, kl, 2772)
FileClose(12)

Dim b1 As Byte
Dim b2 As Byte
Dim b3 As Byte
Dim b4 As Byte
Dim b5 As Byte
Dim b6 As Byte
Dim b7 As Byte
Dim b8 As Byte
Dim hel As Byte
i = 1
j = 1500
i1 = 1
FileOpen(1, FI, OpenMode.Random)
Do While (Not EOF(1)) ' And
If (i1 > Len(tx)) Then
FileClose(1)
Exit Sub
End If
j = j + 10
temp = Mid(t, i1, l) ' t is the reversed text
i1 = i1 + 1
'''Call chang_temp(temp)
hel = Asc(temp) 'to make char -> byte
FileGet(1, b1, j + 1)
FileGet(1, b2, j + 2)
FileGet(1, b3, j + 3)
FileGet(1, b4, j + 4)
FileGet(1, b5, j + 5)
FileGet(1, b6, j + 6)
FileGet(1, b7, j + 7)
FileGet(1, b8, j + 8)
Call by8set(hel, b1, b2, b3, b4, b5, b6, b7, b8)
FilePut(1, b1, j + 1)
FilePut(1, b2, j + 2)
FilePut(1, b3, j + 3)
FilePut(1, b4, j + 4)
FilePut(1, b5, j + 5)
FilePut(1, b6, j + 6)
FilePut(1, b7, j + 7)
FilePut(1, b8, j + 8)
Loop
FileClose(1)
MsgBox("file was to small the letters count entered was only" &
Str(i1))
End Sub

Public Sub enc_in_img(ByRef fpath As String, ByRef txt As String)

End Sub
Public Sub dec_frm_img(ByRef fpath As String, ByRef txt As String)

End Sub
'this will spread your byte on 8 bytes
Public Sub by8set(ByRef mainb As Byte, ByRef b1 As Byte, ByRef b2 As
Byte, ByRef b3 As Byte, ByRef b4 As Byte, ByRef b5 As Byte, ByRef b6 As
Byte, ByRef b7 As Byte, ByRef b8 As Byte)
Dim u As Object
'bits_to_byte(ByRef b As Byte, ByRef bits As bits_array)
'byte_to_bits(ByVal b As Byte, ByRef bits As bits_array)
Dim p10 As New alaa_image.bits_array
Dim p20 As New alaa_image.bits_array
' p10 = New bits_array
p10.Initialize()
p20.Initialize()
For u = 0 To 7
p10.bits(u) = False
'
p20.bits(u) = False
Next u
Call byte_to_bits(mainb, p10)
'no one should touch p10
Call byte_to_bits(b1, p20)
p20.bits(0) = p10.bits(0)
Call bits_to_byte(b1, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b2, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(1)
Call bits_to_byte(b2, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b3, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(2)
Call bits_to_byte(b3, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b4, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(3)
Call bits_to_byte(b4, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b5, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(4)
Call bits_to_byte(b5, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b6, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(5)
Call bits_to_byte(b6, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b7, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(6)
Call bits_to_byte(b7, p20)
'now we stored 1 bit of our byte
Call byte_to_bits(b8, p20) ''is it nessessry to reinitialize p20
here?
p20.bits(0) = p10.bits(7)
Call bits_to_byte(b8, p20)
'now we stored 1 bit of our byte
End Sub
'this will collect your byte on 8 bytes
Public Sub by8get(ByRef mainb As Byte, ByRef b1 As Byte, ByRef b2 As
Byte, ByRef b3 As Byte, ByRef b4 As Byte, ByRef b5 As Byte, ByRef b6 As
Byte, ByRef b7 As Byte, ByRef b8 As Byte)
Dim u As Object
'Dim p10, p20 As bits_array
'bits_to_byte(ByRef b As Byte, ByRef bits As bits_array)
'byte_to_bits(ByVal b As Byte, ByRef bits As bits_array)
''''Call byte_to_bits(mainb, p10)
'no one should touch p10
Dim p10 As New alaa_image.bits_array
Dim p20 As New alaa_image.bits_array
p10.Initialize()
p20.Initialize()
For u = 0 To 7
'
p10.bits(u) = False
'
p20.bits(u) = False
Next u

Call byte_to_bits(b1, p20)


p10.bits(0) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b2, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(1) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b3, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(2) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b4, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(3) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b5, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(4) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b6, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(5) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b7, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(6) = p20.bits(0)
'now we stored 1 bit of our byte

Call byte_to_bits(b8, p20) ''is it nessessry to reinitialize p20


here?
p10.bits(7) = p20.bits(0)
'now we stored 1 bit of our byte
Call bits_to_byte(mainb, p10)
End Sub
''''''''''''''''''''''''''
'''''''''''''''''''HELPERS OF ADVANCED TEXT ENCRYPTION
Public Sub how_size(ByRef tx As String, ByRef PW As String, ByRef si As
Integer)
Dim C As Object
Dim i As Object
Dim r As Object
Dim l As Object
l = Len(PW)
r = 0
For i = 1 To l
C = Mid(PW, i, 1)
If (Asc(C) > r) Then r = Asc(C)
Next i
si = r * ((Len(tx) / Len(PW)) + 1) * 100
End Sub

Public Sub chang_temp_rev(ByRef t As String)


Dim C As Object
Dim i As Object
Dim l As Object
Dim W As Object
W = ""
l = Len(t)
For i = 1 To l
C = Mid(t, i, 1)
W = W + Chr(Asc(C) - 100)
Next i
t = W
End Sub
Public Sub dec_str(ByRef tx As String, ByRef PW As String, ByRef FI As
String)
Dim tmatem As Object
Dim i1 As Object
Dim j As Object
Dim i As Object
Dim kl As Object
Dim t As Object
Dim temp As String
Dim l As Integer
Dim A() As Short
Call inalize_pd(l, PW, A)
kl = Len(t) + 1
i = 1
j = 0
i1 = 1
FileOpen(1, FI, OpenMode.Random)

Do While ((Not EOF(1)) And (i1 <> kl))


j = j + 1
If j > l Then j = 1
Seek(1, (i + A(j)))
i1 = i1 + l ''this is L not 1 !!
FileGet(1, temp, (i + A(j)))
Call chang_temp_rev(temp)
tmatem = tmatem + temp
i = (i + A(j))
Loop
FileClose(1)
tx = StrReverse(tmatem)
'''tx = Trim(tx)
End Sub
Public Sub adjust_text(ByRef S As String, ByRef PW As String)
Dim l2 As Object
Dim l1 As Object
l1 = Len(PW)
l2 = Len(S)
Do While ((l2 Mod l1) <> 0)
S = S & " "
Loop
End Sub
'Public Sub enc_str(tx As String, PW As String, FI As String)
't = StrReverse(tx)
'Dim temp As String
'Dim l As Long
'Dim A() As Integer
'Call inalize_pd(l, PW, A())
'kl = Len(t) + 1
'i = 1
'j = 0
'i1 = 1
'Open FI For Random As 1
'
'Do While ((Not EOF(1)) And (i1 <> kl))
'j = j + 1
'If j > l Then j = 1
'Seek 1, (i + A(j))
'temp = Mid(t, i1, l)
'i1 = i1 + l ''this is L not 1 !!
'Call chang_temp(temp)
'Put 1, (i + A(j)), temp
'i = (i + A(j))
'Loop
'Close 1
'End Sub
Public Sub chang_temp(ByRef t As String)
Dim C As Object
Dim i As Object
Dim l As Object
Dim W As Object
W = ""
l = Len(t)
For i = 1 To l
C = Mid(t, i, 1)
W = W + Chr(Asc(C) + 100)
Next i
t = W
End Sub
Public Sub inalize_pd(ByRef l As Integer, ByRef P As String, ByRef A()
As Short)
Dim C As Object
Dim i As Object
l = Len(P)
ReDim A(l)
For i = 1 To l
C = Mid(P, i, 1)
A(i) = Asc(C)
Next i
End Sub
'''''''''''''''''''''''''''''''''''''
Public Sub dec_str_do(ByRef tx As String, ByRef PW As String, ByRef FI
As String)
Dim t As String
Dim kl As Short
Dim j As Short
Dim i As Short
Dim i1 As Short
t = StrReverse(tx)
Dim temp As String
Dim l As Integer
Dim A() As Short

Call inalize_pd(l, PW, A)

FileOpen(12, FI, OpenMode.Random)


FileGet(12, kl, 2772)
FileClose(12)

Dim b1 As Byte
Dim b2 As Byte
Dim b3 As Byte
Dim b4 As Byte
Dim b5 As Byte
Dim b6 As Byte
Dim b7 As Byte
Dim b8 As Byte
Dim hel As Byte
i = 1
j = 1500
i1 = 1
FileOpen(1, FI, OpenMode.Random)
Do While (Not EOF(1)) ' And

If (i1 > kl) Then


tx = StrReverse(tx)
MsgBox("exited because i finished my string with success")
FileClose(1)
Exit Sub
End If

j = j + 10
i1 = i1 + 1
FileGet(1, b1, j + 1)
FileGet(1, b2, j + 2)
FileGet(1, b3, j + 3)
FileGet(1, b4, j + 4)
FileGet(1, b5, j + 5)
FileGet(1, b6, j + 6)
FileGet(1, b7, j + 7)
FileGet(1, b8, j + 8)
Call by8get(hel, b1, b2, b3, b4, b5, b6, b7, b8)
tx = tx & Chr(hel)
Loop
tx = StrReverse(tx)
MsgBox("exited because error end of file //text was so big for this
file")
FileClose(1)
End Sub

Public Sub input(ByVal message As String, ByRef myValue As String)


Dim title, defaultValue As String
title = "STEALTH <>ALAA Jebran<>" ' Set title.
defaultValue = ""
myValue = InputBox(message, title, defaultValue)
End Sub
Function odd(ByVal s1) As Boolean 'this function will kill fractional
part and then evaluate when having fractional nums
odd = False
Dim d As Integer
d = Decimal.Truncate(s1)
''MsgBox(d.ToString)
Dim s As String
s = Str(d)
If s.EndsWith("1") Or s.EndsWith("3") Or s.EndsWith("5") Or
s.EndsWith("7") Or s.EndsWith("9") Then
odd = True
End If
End Function
Sub process_pass_with_tx(ByVal ps As String, ByRef tx As String)
Dim l = tx.Length
Dim lp = ps.Length
While lp < l
ps = ps + ps
lp = ps.Length
End While
Dim i
Dim tx1 As String
tx1 = ""
Dim s1, s2
Dim rs As Integer
For i = 0 To l - 1
s1 = (Asc(tx.Chars(i)))
s2 = (Asc(ps.Chars(i)))
rs = (s1 Xor s2)
tx1 = tx1 + Chr(rs)
Next
tx = tx1
End Sub
End Module
JPEG.VB

Imports System.Drawing.Imaging

Public Class jpeg


Inherits System.Windows.Forms.Form

Dim errOcr As Boolean


Private Function GetEncoderInfo(ByVal mimeType As String) As
ImageCodecInfo

Dim j As Integer
Dim encoders As ImageCodecInfo()
encoders = ImageCodecInfo.GetImageEncoders()
For j = 0 To encoders.Length
If encoders(j).MimeType = mimeType Then
Return encoders(j)
End If
Next j
Return Nothing
End Function
Private Sub SaveJPGWithCompressionSetting(ByVal image As Image, ByVal
szFileName As String, ByVal lCompression As Long)
On Error GoTo chkErr
Dim eps As EncoderParameters = New EncoderParameters(1)
eps.Param(0) = New EncoderParameter(Encoder.Quality, lCompression)
Dim ici As ImageCodecInfo = GetEncoderInfo("image/jpeg")
image.Save(szFileName, ici, eps)
Exit Sub
chkErr: MsgBox("Error: " & Err.Number & " " & Err.Description & vbCrLf &
"Choose a different name for file.")
errOcr = True
Resume Next

End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim FileSize As Long
Dim suffit As String
Dim i As Integer
For i = 100 To 5 Step -5
cbCI.Items.Add(i)
Next i
SaveJPGWithCompressionSetting(pbPic.Image, Application.StartupPath &
"\temp100.jpg", 100)
SaveJPGWithCompressionSetting(pbPic.Image, Application.StartupPath &
"\temp.jpg", 100)
cbCI.Text = "100"
FileSize = FileLen(Application.StartupPath & "\temp.jpg")
If FileSize < 1000 Then
suffit = " Bytes"
GoTo showit
End If
If FileSize > 1000000 Then
FileSize = Int(FileSize / 1000000)
suffit = " Mb"
GoTo showit
Else
FileSize = Int(FileSize / 1000)
suffit = " Kb"
End If
showit: lbl100.Text = FileSize & suffit

End Sub

Private Sub btnSaveAs_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnSaveAs.Click
errOcr = False
fdSaveAs.Title = "Select the image to Save As."
fdSaveAs.Filter = "Jpeg Images(.jpg)|*.jpg"
If fdSaveAs.ShowDialog() = DialogResult.OK Then
'Allow pbPic.Image to be saved to temp.jpg
Dim bm As Bitmap = Image.FromFile(Application.StartupPath &
"\temp100.jpg")
'Release loaded file temp.jpg
If Not (pbPic.Image Is Nothing) Then
pbPic.Image.Dispose()
pbPic.Image = Nothing
End If
'=====
SaveJPGWithCompressionSetting(bm, fdSaveAs.FileName,
Val(cbCI.Text))
'Still error if you try to save pbPic.Image to temp100.jpg
If errOcr Then
errOcr = False
pbPic.Image = bm
Exit Sub
End If
bm.Dispose()
pbPic.Image = Image.FromFile(fdSaveAs.FileName)
End If
End Sub

Private Sub cbCI_SelectedIndexChanged(ByVal sender As Object, ByVal e As


System.EventArgs) Handles cbCI.SelectedIndexChanged
'Release loaded file temp.jpg
If Not (pbPic.Image Is Nothing) Then
pbPic.Image.Dispose()
pbPic.Image = Nothing
End If
'=====
'Release temp100.jpg after load
Dim bmi As Bitmap = Image.FromFile(Application.StartupPath &
"\temp100.jpg")
pbPic.Image = bmi
SaveJPGWithCompressionSetting(pbPic.Image, Application.StartupPath &
"\temp.jpg", Val(cbCI.Text))
bmi.Dispose()
'====
pbPic.Image = Image.FromFile(Application.StartupPath & "\temp.jpg")
lblCI.Text = cbCI.Text
Dim FileSize As Long
Dim suffit As String
FileSize = FileLen(Application.StartupPath & "\temp.jpg")
If FileSize < 1000 Then
suffit = " Bytes"
GoTo showit
End If
If FileSize > 1000000 Then
FileSize = Int(FileSize / 1000000)
suffit = " Mb"
GoTo showit
Else
FileSize = Int(FileSize / 1000)
suffit = " Kb"
End If
showit: lblTemp.Text = FileSize & suffit

End Sub

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As


System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
On Error GoTo chkErr
'The Kill Function will not work if file is being used in a process
pbPic.Image.Dispose() 'temp.jpg was in pbPic.Image
Kill(Application.StartupPath & "\temp.jpg")
Kill(Application.StartupPath & "\temp100.jpg")
Exit Sub
chkErr: MsgBox("Error: " & Err.Number & " " & Err.Description & vbCrLf &
"File will not be deleted :(")
Resume Next
End Sub
End Class
JPEGCOMPRESSION.VB
Imports System.Drawing.Imaging
Imports System.IO

Module JpegCompression

' Get a codec's information.


Private Function GetEncoderInfo(ByVal mimeType As String) As
ImageCodecInfo
Dim encoders As ImageCodecInfo()
encoders = ImageCodecInfo.GetImageEncoders()
For i As Integer = 0 To encoders.Length
If encoders(i).MimeType = mimeType Then
Return encoders(i)
End If
Next i
Return Nothing
End Function

' Save a JPEG in compressed form.


' The compression_level value
' should be between 10 and 100.
Public Sub SaveCompressedJpeg(ByVal image As Image, ByVal file_name As
String, ByVal compression_level As Long)
If compression_level < 10 Then
Throw New ArgumentException("Compression level must be between
10 and 100")
End If

' Get an encoder parameter array and set the compression level.
Dim encoder_params As EncoderParameters = New EncoderParameters(1)
encoder_params.Param(0) = New EncoderParameter(Encoder.Quality,
compression_level)

' Prepare the codec to encode.


Dim image_codec_info As ImageCodecInfo =
GetEncoderInfo("image/jpeg")

' Save the file.


Dim mem As New MemoryStream()
image.Save(mem, image_codec_info, encoder_params)

image.Save(file_name, image_codec_info, encoder_params)


End Sub

' Save a JPEG in compressed form into a memory stream.


' The compression_level value
' should be between 10 and 100.
Public Function SaveJpegIntoStream(ByVal image As Image, ByVal
compression_level As Long) As MemoryStream
If compression_level < 10 Then
Throw New ArgumentException("Compression level must be between
10 and 100")
End If
' Get an encoder parameter array and set the compression level.
Dim encoder_params As EncoderParameters = New EncoderParameters(1)
encoder_params.Param(0) = New EncoderParameter(Encoder.Quality,
compression_level)

' Prepare the codec to encode.


Dim image_codec_info As ImageCodecInfo =
GetEncoderInfo("image/jpeg")

' Save the file.


Dim memory_stream As New MemoryStream()
image.Save(memory_stream, image_codec_info, encoder_params)

Return memory_stream
End Function
End Module
COMPRESSIONPAGE.VB

Imports System.Drawing.Imaging

Public Class compressionpage

Private Sub textcompress_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New textfilecompress
f.Show()

End Sub
Private m_Alpha As Single = 0 ' Alpha on a 0-1 scale.
Private m_DAlpha As Single = 0.05

Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)
picResult.Image = bm
picResult.Refresh()
m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

Private Sub imageanalyse_LinkClicked(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
imageanalyse.LinkClicked
Dim f As New imageanalyservb
f.Show()

End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel1.LinkClicked
Dim f As New imageformat
f.Show()

End Sub

Private Sub jpeg_LinkClicked(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles jpeg.LinkClicked
Dim f As New jpeg
f.Show()

End Sub

Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
jpeg1.LinkClicked
Dim f As New jpeg1
f.Show()

End Sub

Private Sub Button1_LinkClicked(ByVal sender As System.Object, ByVal e


As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
Button1.LinkClicked
Dim f As New imageconvert
f.Show()

End Sub

Private Sub LinkLabel2_LinkClicked_1(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel2.LinkClicked
Dim f As New textfilecompress
f.Show()

End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs)
End Sub
End Class
CRYPTOPAGE.VB
Public Class cryptopage
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim f As New Transposition
f.Show()
End Sub
Private Sub textsteg_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim f As New teststegano
f.Show()
End Sub

Private Sub stringcomprcry_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs)
Dim f As New stringcomcry
f.Show()
End Sub

Private Sub sdes_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New DES1
f.Show()
End Sub

Private Sub fileDES_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New fileDES
f.Show()
End Sub

Private Sub encr_file_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New fileencrypt
f.Show()
End Sub

Private Sub img_steg_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
End Sub

Private Sub pic_key_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
Dim f As New pic_keyvb
f.Show()
End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
textsteg1.LinkClicked
Dim f As New teststegano
f.Show()
End Sub
Private Sub LinkLabel1_LinkClicked_2(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
pic_keyvb.LinkClicked
Dim f As New pic_keyvb
f.Show()
End Sub

Private Sub LinkLabel1_LinkClicked_3(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
comprcry.LinkClicked
Dim f As New Transposition
f.Show()
End Sub

Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel4.LinkClicked
Dim f As New fileDES
f.Show()
End Sub

Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel2.LinkClicked
Dim f As New stringcomcry
f.Show()
End Sub

Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel3.LinkClicked
Dim f As New DES1
f.Show()
End Sub

Private Sub LinkLabel5_LinkClicked(ByVal sender As System.Object, ByVal


e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
LinkLabel5.LinkClicked
Dim f As New fileencrypt
f.Show()
End Sub

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.PaintEventArgs)
End Sub
End Class
DES1.VB
Imports System.Drawing.Imaging

Public Class DES1

Inherits System.Windows.Forms.Form

Dim frm3 As New DES2()

Public bincipher, key1, key2, sp1, sp2, sbxout, swtch_out, expout,


xrout, xr4out, pbox4out As String
Dim IntNum As Integer
Dim x As Integer
Dim BinValue, lout, fk2input1, fk2input2, rnd2xpout, expky2 As String
Dim sout, rnd2sp1, rnd2sp2, rnd2sbx, rnd2p4out, rnd2xr4out As String

Dim ls1, rnd2fin_str, rndinv_pout As String


Dim left1 As String
Dim ls2 As String
Dim left2 As String
Dim leftshift, p4out As String
Dim temp As String

Dim kypermut(8) As Integer


Dim keypermut(10) As Integer
Dim iniperm(8) As Integer
Dim invperm(8) As Integer
Dim experm(8) As Integer
Dim p4perm(4) As Integer
Dim sbox1(4, 4) As Integer
Dim sbox2(4, 4) As Integer

Dim tmp1 As String


Dim tmp2 As String
Dim P8input As String

Dim lp As Integer
Dim w1, w2 As String

Dim cpyls1 As String


Dim cpyls2 As String

Dim txt As Integer


Dim plntxt As String

Dim lft1 As String


Dim lft2 As String
Dim tp1 As String
Dim tp2 As String
Dim lsift1 As String
Dim lsift2 As String
Dim P8input2, p8inpt, edkey1, edkey2 As String
Dim P10input As String

Dim pp As Integer
Dim IP As String

Dim lpt As Integer


Dim wo1 As String
Dim split1 As String
Dim split2 As String

Dim cpsplit1 As String


Dim cpsplit2 As String

Dim xp, inresult As String


Dim exp As Integer
Dim p8inpt2 As String
Private m_Alpha As Single = 0 ' Alpha on a 0-1 scale.
Private m_DAlpha As Single = 0.05
Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

picResult.Image = bm
picResult.Refresh()

m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

Private Function key_perm(ByVal key_str As String)

kypermut(0) = 6 : kypermut(1) = 3 : kypermut(2) = 7 : kypermut(3) =


4
kypermut(4) = 8 : kypermut(5) = 5 : kypermut(6) = 10 : kypermut(7) =
9

Dim loc_int As Integer


Dim loc_str As String
Dim res_str As String

loc_str = key_str

For loc_int = 0 To 7
res_str = res_str & Mid(loc_str, kypermut(loc_int), 1)

Next
key_perm = res_str

End Function

Public Function P10permut(ByVal p10_str As String)


keypermut(0) = 3 : keypermut(1) = 5
keypermut(2) = 2 : keypermut(3) = 7
keypermut(4) = 4 : keypermut(5) = 10
keypermut(6) = 1 : keypermut(7) = 9
keypermut(8) = 8 : keypermut(9) = 6
Dim loc_int As Integer
Dim loc_str As String
Dim s As String

loc_str = p10_str

For loc_int = 0 To 9
s = s & Mid(loc_str, keypermut(loc_int), 1)
Next
P10permut = s

End Function

Public Function lshift(ByVal ls_str1 As String, ByVal ls_str2 As String)


Dim left_str1, llft1, llft2, tmpo1, tmpo2, left_str2 As String
Dim p8inpt1 As String

left_str1 = ls_str1
left_str2 = ls_str2

'msgbox(left_str1 & "------" & left_str2)

llft1 = Mid(left_str1, 1, 1)
tmpo1 = Mid(left_str1, 2, 5)
left_str1 = tmpo1 & llft1

llft2 = Mid(left_str2, 1, 1)
tmpo2 = Mid(left_str2, 2, 5)
left_str2 = tmpo2 & llft2

'msgbox("after shift" & left_str1 & "------" & left_str2)

cpyls1 = left_str1
frm3.TextBox2.Text = cpyls1
cpyls2 = left_str2
frm3.TextBox3.Text = cpyls2
p8inpt1 = left_str1 & left_str2

lshift = p8inpt1

End Function

Public Function keygen(ByVal key As Integer)


Dim TempValue As Integer
Dim integr As Integer

integr = Val(key)
Do
TempValue = integr Mod 2
BinValue = CStr(TempValue) + BinValue
integr = integr \ 2

Loop Until integr = 0

If Len(BinValue) < 10 Then

Dim t, i As Integer

t = 10 - Len(BinValue)

For i = 1 To t
temp = (temp) + "0"
Next
ElseIf Len(BinValue) > 10 Then
MsgBox("S-DES accepts only 10 bit key")
BinValue = ""
temp = ""
Exit Function
End If

Dim p8in1, p8in2, ls_s1, ls_s2, p10input, p10output, lftsift As


String

p10input = temp + BinValue

'P10input = leftshift
p10output = P10permut(p10input)
frm3.TextBox1.Text = p10output
)

lftsift = p10output
'************divide into 5 bits each**************

ls_s1 = Mid(lftsift, 1, 5)
ls_s2 = Mid(lftsift, 6, 10)

' MsgBox(ls1 & "------" & ls2)


p8in1 = lshift(ls_s1, ls_s2)
'msgbox("p8 comp perm1=" & p8in1)

edkey1 = key_perm(p8in1)
frm3.TextBox4.Text = edkey1
'MsgBox("key1=" & edkey1)
TextBox5.Text = edkey1

Dim ls0_s1, ls0_s2 As String

p8in2 = lshift(cpyls1, cpyls2)

ls0_s1 = Mid(p8in2, 1, 5)
frm3.TextBox5.Text = ls0_s1
ls0_s2 = Mid(p8in2, 6, 10)
frm3.TextBox6.Text = ls0_s2

'msgbox("p8 comp perm2=" & p8in2)

edkey2 = key_perm(p8in2)

TextBox6.Text = edkey2

frm3.TextBox7.Text = edkey2
'MsgBox("key2=" & edkey2)

'*****clear values

BinValue = ""
leftshift = ""
temp = ""
cpyls2 = ""
cpyls1 = ""
End Function

Public Function Enc_Decrypt(ByVal input_str As String, ByVal ky1 As


String, ByVal ky2 As String)

key1 = ky1
key2 = ky2

Dim TempValue As Integer


Dim rnd2inv_pout As String
txt = (Asc(input_str))
'msgbox(txt)
IntNum = txt
Do
TempValue = IntNum Mod 2
BinValue = CStr(TempValue) + BinValue
IntNum = IntNum \ 2

Loop Until IntNum = 0

If Len(BinValue) < 8 Then

Dim t, i As Integer

t = 8 - Len(BinValue)

For i = 1 To t
temp = (temp) + "0"
Next
ElseIf Len(BinValue) > 8 Then
MsgBox("S-DES accepts only 8 bit PlainText")
BinValue = ""
temp = ""
Exit Function
'msgbox(BinValue)
BinValue = ""
temp = ""
End If
plntxt = (temp + BinValue)
'msgbox(plntxt)

IP = InitPerm(plntxt)
'msgbox("Initial Permutation output=" & IP)
frm3.TextBox8.Text = IP

split1 = Mid(IP, 1, 4)
split2 = Mid(IP, 5, 8)

cpsplit1 = split1
cpsplit2 = split2

expout = ExpPrm(split2)
frm3.TextBox9.Text = expout
'********Xor************

xrout = xor8bit(expout, key1)


frm3.TextBox10.Text = xrout

'**********split into 4 bits*******

sp1 = Mid(xrout, 1, 4)

sp2 = Mid(xrout, 5, 8)

sbxout = Sbox(sp1, sp2)


frm3.TextBox11.Text = sbxout

pbox4out = P4permut(sbxout)
frm3.TextBox13.Text = pbox4out

xr4out = xor4bit(cpsplit1, pbox4out)


frm3.TextBox14.Text = xr4out

'**********switching********
swtch_out = SW_switch(xr4out, cpsplit2)
frm3.TextBox15.Text = swtch_out

'*************Fk2 next round****

fk2input1 = cpsplit2
fk2input2 = xr4out

rnd2xpout = ExpPrm(fk2input2)

frm3.TextBox16.Text = rnd2xpout
expky2 = xor8bit(rnd2xpout, key2)
frm3.TextBox17.Text = expky2

rnd2sp1 = Mid(expky2, 1, 4)
rnd2sp2 = Mid(expky2, 5, 8)

rnd2sbx = Sbox(rnd2sp1, rnd2sp2)


frm3.TextBox18.Text = rnd2sbx
rnd2p4out = P4permut(rnd2sbx)
frm3.TextBox19.Text = rnd2p4out
rnd2xr4out = xor4bit(fk2input1, rnd2p4out)
frm3.TextBox20.Text = rnd2xr4out
rnd2fin_str = rnd2xr4out & fk2input2
rnd2inv_pout = InvPrm(rnd2fin_str)
frm3.TextBox21.Text = rnd2inv_pout

bincipher = rnd2inv_pout
Enc_Decrypt = Chr(BinToInt(rnd2inv_pout))

'********clearing values ****


BinValue = ""
temp = ""
IP = ""
split1 = ""
split2 = ""
xp = ""
inresult = ""
sp1 = ""
sp2 = ""
lout = ""

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

'*******generate binary keys*****


keygen(Val(TextBox1.Text))
Button2.Enabled = True

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Dim sdr As String
Dim fin As String
Dim i As Integer

TextBox7.Text = ""
TextBox8.Text = ""
For i = 1 To Len(TextBox2.Text)
sdr = Mid(TextBox2.Text, i, 1)
fin = fin & Enc_Decrypt(sdr, edkey1, edkey2)

TextBox7.Text = TextBox7.Text & plntxt


TextBox8.Text = TextBox8.Text & bincipher
Next
TextBox3.Text = fin
Button3.Enabled = True
plntxt = ""
bincipher = ""
End Sub

Public Function InitPerm(ByVal pltxt As String)

Dim pp As Integer
Dim Initial_Permutation As String
Dim plxt As String

iniperm(0) = 2 : iniperm(1) = 6 : iniperm(2) = 3 : iniperm(3) = 1


iniperm(4) = 4 : iniperm(5) = 8 : iniperm(6) = 5 : iniperm(7) = 7

plxt = pltxt

For pp = 0 To 7
Initial_Permutation = Initial_Permutation & Mid(plxt,
iniperm(pp), 1)
Next

InitPerm = Initial_Permutation

End Function

Public Function InvPrm(ByVal invprm_str As String)


Dim tmp_ivp, invout As String
Dim i As Integer
tmp_ivp = invprm_str

invperm(0) = 4 : invperm(1) = 1 : invperm(2) = 3 : invperm(3) = 5


invperm(4) = 7 : invperm(5) = 2 : invperm(6) = 8 : invperm(7) = 6

For i = 0 To 7
invout = invout & Mid(tmp_ivp, invperm(i), 1)
Next
InvPrm = invout

End Function

Public Function ExpPrm(ByVal split_str As String)


Dim local1, splistr_2 As String
Dim i As Integer
splistr_2 = split_str
experm(0) = 4 : experm(1) = 1 : experm(2) = 2 : experm(3) = 3
experm(4) = 2 : experm(5) = 3 : experm(6) = 4 : experm(7) = 1

For i = 0 To 7
local1 = local1 & Mid(splistr_2, experm(i), 1)
Next
ExpPrm = local1

End Function

Public Function P4permut(ByVal str_4bit As String)


Dim p4 As String
Dim ex As Integer
Dim lostr As String

lostr = str_4bit
p4perm(0) = 2 : p4perm(1) = 4 : p4perm(2) = 3 : p4perm(3) = 1

For ex = 0 To 3
p4 = p4 & Mid(lostr, p4perm(ex), 1)
Next
P4permut = p4

End Function

Public Function Sbox(ByVal sbox_str1 As String, ByVal sbox_str2 As


String)

Dim left4bit, right4bit As String


sbox1(0, 0) = 1 : sbox1(0, 1) = 0 : sbox1(0, 2) = 3 : sbox1(0, 3) =
2
sbox1(1, 0) = 3 : sbox1(1, 1) = 2 : sbox1(1, 2) = 1 : sbox1(1, 3) =
0
sbox1(2, 0) = 0 : sbox1(2, 1) = 2 : sbox1(2, 2) = 1 : sbox1(2, 3) =
3
sbox1(3, 0) = 3 : sbox1(3, 1) = 1 : sbox1(3, 2) = 3 : sbox1(3, 3) =
2

sbox2(0, 0) = 0 : sbox2(0, 1) = 1 : sbox2(0, 2) = 2 : sbox2(0, 3) =


3
sbox2(1, 0) = 2 : sbox2(1, 1) = 0 : sbox2(1, 2) = 1 : sbox2(1, 3) =
3
sbox2(2, 0) = 3 : sbox2(2, 1) = 0 : sbox2(2, 2) = 1 : sbox2(2, 3) =
0
sbox2(3, 0) = 2 : sbox2(3, 1) = 1 : sbox2(3, 2) = 0 : sbox2(3, 3) =
3

left4bit = sbox_str1
right4bit = sbox_str2

Dim i, ia As Integer
Dim s, s1, s2, s3 As String
Dim z1, z2 As Integer

For i = 1 To 4
s = s & Mid(left4bit, i, 1)
i += 2
Next
For i = 2 To 3
s1 = s1 & Mid(left4bit, i, 1)

Next

For i = 1 To 4
s2 = s2 & Mid(right4bit, i, 1)
i += 2
Next

For i = 2 To 3
s3 = s3 & Mid(right4bit, i, 1)

Next

Dim want1, want2 As String

sout = (IntToBin(sbox1(BinToInt(s), BinToInt(s1)))) &


(IntToBin(sbox2(BinToInt(s2), BinToInt(s3))))

Sbox = sout

End Function

Public Sub Sbx2()

End Sub

Function BinToInt(ByVal BinaryNumber As String)

Dim Length As Integer


Dim TempValu As Integer
Length = Len(BinaryNumber)

For x = 1 To Length
TempValu = TempValu + Val(Mid(BinaryNumber, Length - x + 1, 1))
* 2 ^ (x - 1)
Next

BinToInt = TempValu

End Function

Function IntToBin(ByVal IntegerNumber As Long)

IntNum = IntegerNumber
Dim TempVa As Integer
Dim binval As String
Do

TempVa = IntNum Mod 2


binval = CStr(TempVa) + binval

IntNum = IntNum \ 2
Loop Until IntNum = 0

If Len(binval) < 2 Then


binval = "0" + binval
End If

IntToBin = binval

End Function

Public Function xor8bit(ByVal str_expout As String, ByVal str_key As


String)
Dim re As Integer
Dim inre, locstr1, locstr2 As String
Dim insul As Integer

locstr1 = str_expout
locstr2 = str_key

For re = 1 To 8
inre = inre & (Mid(locstr1, re, 1) Xor Mid(locstr2, re, 1))
Next
xor8bit = inre

End Function

Public Function xor4bit(ByVal lft_ipstr As String, ByVal p4_boxout As


String)
Dim i4 As Integer
Dim loclout, lftstr, pbx4out As String

lftstr = lft_ipstr
pbx4out = p4_boxout

For i4 = 1 To 4
loclout = loclout & (Mid(lftstr, i4, 1) Xor Mid(pbx4out, i4, 1))
Next

xor4bit = loclout

End Function

Public Function SW_switch(ByVal str1_swch As String, ByVal str2_swch As


String)
Dim bufstr1 As String
Dim bufstr2 As String
bufstr1 = str1_swch
bufstr2 = str2_swch
SW_switch = bufstr2 & bufstr1

End Function

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click

TextBox4.Text = ""

Dim sdr As String


Dim fin As String
Dim i As Integer

For i = 1 To Len(TextBox3.Text)
sdr = Mid(TextBox3.Text, i, 1)

fin = fin & Enc_Decrypt(sdr, edkey2, edkey1)


Next
TextBox4.Text = fin
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
End
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
frm3.Show()
End Sub
End Class
DES2.VB

Public Class DES2

Inherits System.Windows.Forms.Form

Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label4.Click

End Sub
Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox3.Enter

End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub
Private Sub Label14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label14.Click

End Sub
Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox10.TextChanged

End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.TextChanged

End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox4.TextChanged

End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label2.Click

End Sub
Private Sub Label12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub
Private Sub TextBox15_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox15.TextChanged

End Sub
Private Sub TextBox14_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox14.TextChanged

End Sub
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox11.TextChanged

End Sub
Private Sub Label13_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox6.TextChanged

End Sub
Private Sub Label15_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label15.Click

End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged

End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label7.Click

End Sub
Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox2.Enter

End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox2.TextChanged

End Sub
Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox5.TextChanged

End Sub
Private Sub TextBox13_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox13.TextChanged

End Sub
Private Sub Label10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label10.Click

End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GroupBox1.Enter

End Sub
Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox7.TextChanged

End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label5.Click

End Sub
Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label11.Click

End Sub
Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs)

End Sub
Private Sub Label16_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label16.Click

End Sub
Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label8.Click

End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox9.TextChanged

End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label1.Click

End Sub
Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label9.Click

End Sub
Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox8.TextChanged

End Sub

Private Sub TextBox22_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs)

End Sub
End Class
FILE DES .VB
Imports System.IO
Imports System.Security
Imports System.Security.Cryptography
Public Class fileDES
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim file_path As String = Application.StartupPath
file_path = file_path.Substring(0, file_path.LastIndexOf("\"))
txtPlaintext.Text = file_path & "\text.dat"
txtPlaintextFile.Text = file_path & "\plaintext.txt"
txtCiphertextFile.Text = file_path & "\cyphertext.dat"
txtDecipheredFile.Text = file_path & "\decyphered.txt"
txtPlaintext.Text = GrabFile(txtPlaintextFile.Text)
End Sub

Private Sub CryptFile(ByVal password As String, ByVal in_file As String,


ByVal out_file As String, ByVal encrypt As Boolean)
Dim in_stream As New FileStream(in_file, FileMode.Open,
FileAccess.Read)
Dim out_stream As New FileStream(out_file, FileMode.Create,
FileAccess.Write)

Dim des_provider As New TripleDESCryptoServiceProvider

Dim key_size_bits As Integer = 0


For i As Integer = 1024 To 1 Step -1
If des_provider.ValidKeySize(i) Then
key_size_bits = i
Exit For
End If
Next i
Debug.Assert(key_size_bits > 0)

Dim block_size_bits As Integer = des_provider.BlockSize


Dim key As Byte() = Nothing
Dim iv As Byte() = Nothing
MakeKeyAndIV(password, key_size_bits, block_size_bits, key, iv)

Dim crypto_transform As ICryptoTransform


If encrypt Then
crypto_transform = des_provider.CreateEncryptor(key, iv)
Else
crypto_transform = des_provider.CreateDecryptor(key, iv)
End If

Dim crypto_stream As New CryptoStream(out_stream,


crypto_transform, CryptoStreamMode.Write)

Const BLOCK_SIZE As Integer = 1024


Dim buffer(BLOCK_SIZE) As Byte
Dim bytes_read As Integer
Do
bytes_read = in_stream.Read(buffer, 0, BLOCK_SIZE)
If bytes_read = 0 Then Exit Do

crypto_stream.Write(buffer, 0, bytes_read)
Loop

crypto_stream.Close()
in_stream.Close()
out_stream.Close()
End Sub

Private Sub MakeKeyAndIV(ByVal password As String, ByVal key_size_bits


As Integer, ByVal block_size_bits As Integer, ByRef key As Byte(), ByRef iv
As Byte())
Dim password_derive_bytes As New PasswordDeriveBytes( _
password, Nothing, "SHA384", 1000)

key = password_derive_bytes.GetBytes(key_size_bits \ 8)
iv = password_derive_bytes.GetBytes(block_size_bits \ 8)
End Sub

Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnEncrypt.Click
CryptFile(txtPassword.Text, txtPlaintextFile.Text,
txtCiphertextFile.Text, True)

txtCiphertext.Text = GrabFile(txtCiphertextFile.Text)
End Sub

Private Sub btnDecrypt_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnDecrypt.Click
CryptFile(txtPassword.Text, txtCiphertextFile.Text,
txtDecipheredFile.Text, False)

txtDeciphered.Text = GrabFile(txtDecipheredFile.Text)
End Sub

Private Function GrabFile(ByVal file_name As String) As String


Try
Dim stream_reader As New IO.StreamReader(file_name)
Dim txt As String = stream_reader.ReadToEnd()
stream_reader.Close()
Return txt
Catch exc As System.IO.FileNotFoundException
Return ""
Catch exc As Exception

MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read Error")


Return ""
End Try
End Function
End Class
FILEENCRYPT.VB
Imports System
Imports System.IO
Imports System.Drawing.imaging
Imports System.Security
Imports System.Security.Cryptography
Public Class fileencrypt

Inherits System.Windows.Forms.Form

#Region "1. Global Variables "

Dim strFileToEncrypt As String


Dim strFileToDecrypt As String
Dim strOutputEncrypt As String
Dim strOutputDecrypt As String
Dim fsInput As System.IO.FileStream
Dim fsOutput As System.IO.FileStream

#End Region

#Region "2. Create A Key "

Private Function CreateKey(ByVal strPassword As String) As Byte()


Dim chrData() As Char = strPassword.ToCharArray
Dim intLength As Integer = chrData.GetUpperBound(0)

Dim bytDataToHash(intLength) As Byte

For i As Integer = 0 To chrData.GetUpperBound(0)


bytDataToHash(i) = CByte(Asc(chrData(i)))
Next

Dim SHA512 As New System.Security.Cryptography.SHA512Managed

Dim bytResult As Byte() = SHA512.ComputeHash(bytDataToHash)


Dim bytKey(31) As Byte

For i As Integer = 0 To 31
bytKey(i) = bytResult(i)
Next

Return bytKey End Function

#End Region

#Region "3. Create An IV "


Private Function CreateIV(ByVal strPassword As String) As Byte()

Dim chrData() As Char = strPassword.ToCharArray


Dim intLength As Integer = chrData.GetUpperBound(0)
Dim bytDataToHash(intLength) As Byte

For i As Integer = 0 To chrData.GetUpperBound(0)


bytDataToHash(i) = CByte(Asc(chrData(i)))
Next

Dim SHA512 As New System.Security.Cryptography.SHA512Managed


Dim bytResult As Byte() = SHA512.ComputeHash(bytDataToHash)
Dim bytIV(15) As Byte

For i As Integer = 32 To 47
bytIV(i - 32) = bytResult(i)
Next

Return bytIV End Function

#End Region

#Region "4. Encrypt / Decrypt File "

Private Enum CryptoAction


ActionEncrypt = 1
ActionDecrypt = 2
End Enum

Private Sub EncryptOrDecryptFile(ByVal strInputFile As String, _


ByVal strOutputFile As String, _
ByVal bytKey() As Byte, _
ByVal bytIV() As Byte, _
ByVal Direction As CryptoAction)
Try
fsInput = New System.IO.FileStream(strInputFile, FileMode.Open,
_
FileAccess.Read)
fsOutput = New System.IO.FileStream(strOutputFile,
FileMode.OpenOrCreate, _
FileAccess.Write)
fsOutput.SetLength(0)
Dim bytBuffer(4096) As Byte Dim lngBytesProcessed As
Long = 0 Dim lngFileLength As Long = fsInput.Length
Dim intBytesInCurrentBlock As Integer Dim csCryptoStream As
CryptoStream

Dim cspRijndael As New


System.Security.Cryptography.RijndaelManaged
pbStatus.Value = 0
pbStatus.Maximum = 100

Select Case Direction


Case CryptoAction.ActionEncrypt
csCryptoStream = New CryptoStream(fsOutput, _
cspRijndael.CreateEncryptor(bytKey, bytIV), _
CryptoStreamMode.Write)
Case CryptoAction.ActionDecrypt
csCryptoStream = New CryptoStream(fsOutput, _
cspRijndael.CreateDecryptor(bytKey, bytIV), _
CryptoStreamMode.Write)
End Select

While lngBytesProcessed < lngFileLength


intBytesInCurrentBlock =
fsInput.Read(bytBuffer, 0, 4096)

csCryptoStream.Write(bytBuffer, 0, intBytesInCurrentBlock)
lngBytesProcessed = lngBytesProcessed +
CLng(intBytesInCurrentBlock)
pbStatus.Value = CInt((lngBytesProcessed /
lngFileLength) * 100)
End While

csCryptoStream.Close()
fsInput.Close()
fsOutput.Close()

.
If Direction = CryptoAction.ActionEncrypt Then
Dim fileOriginal As New FileInfo(strFileToEncrypt)
fileOriginal.Delete()
End If

If Direction = CryptoAction.ActionDecrypt Then


Dim fileEncrypted As New FileInfo(strFileToDecrypt)
fileEncrypted.Delete()
End If

Dim Wrap As String = Chr(13) + Chr(10)


If Direction = CryptoAction.ActionEncrypt Then
MsgBox("Encryption Complete" + Wrap + Wrap + _
"Total bytes processed = " + _
lngBytesProcessed.ToString, _
MsgBoxStyle.Information, "Done")

pbStatus.Value = 0
txtFileToEncrypt.Text = "Click Browse to load file."
txtPassEncrypt.Text = ""
txtConPassEncrypt.Text = ""
txtDestinationEncrypt.Text = ""
btnChangeEncrypt.Enabled = False
btnEncrypt.Enabled = False

Else
MsgBox("Decryption Complete" + Wrap + Wrap + _
"Total bytes processed = " + _
lngBytesProcessed.ToString, _
MsgBoxStyle.Information, "Done")
pbStatus.Value = 0
txtFileToDecrypt.Text = "Click Browse to load file."
txtPassDecrypt.Text = ""
txtConPassDecrypt.Text = ""
txtDestinationDecrypt.Text = ""
btnChangeDecrypt.Enabled = False
btnDecrypt.Enabled = False
End If

Catch When Err.Number = 53 'if file not found


MsgBox("Please check to make sure the path and filename" + _
"are correct and if the file exists.", _
MsgBoxStyle.Exclamation, "Invalid Path or Filename")

Catch
fsInput.Close()
fsOutput.Close()

If Direction = CryptoAction.ActionDecrypt Then


Dim fileDelete As New FileInfo(txtDestinationDecrypt.Text)
fileDelete.Delete()
pbStatus.Value = 0
txtPassDecrypt.Text = ""
txtConPassDecrypt.Text = ""

MsgBox("Please check to make sure that you entered the


correct" + _
"password.", MsgBoxStyle.Exclamation, "Invalid
Password")
Else
Dim fileDelete As New FileInfo(txtDestinationEncrypt.Text)
fileDelete.Delete()

pbStatus.Value = 0
txtPassEncrypt.Text = ""
txtConPassEncrypt.Text = ""

MsgBox("This file cannot be encrypted.", _


MsgBoxStyle.Exclamation, "Invalid File")

End If

End Try
End Sub

#End Region

#Region "5. Browse / Change Button "

Private Sub btnBrowseEncrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnBrowseEncrypt.Click
OpenFileDialog.FileName = ""
OpenFileDialog.Title = "Choose a file to encrypt"
OpenFileDialog.InitialDirectory = "C:\"
OpenFileDialog.Filter = "All Files (*.*) | *.*"

If OpenFileDialog.ShowDialog = DialogResult.OK Then


strFileToEncrypt = OpenFileDialog.FileName
txtFileToEncrypt.Text = strFileToEncrypt

Dim iPosition As Integer = 0


Dim i As Integer = 0

While strFileToEncrypt.IndexOf("\"c, i) <> -1


iPosition = strFileToEncrypt.IndexOf("\"c, i)
i = iPosition + 1
End While
strOutputEncrypt = strFileToEncrypt.Substring(iPosition + 1)
Dim S As String = strFileToEncrypt.Substring(0, iPosition + 1)
strOutputEncrypt = strOutputEncrypt.Replace("."c, "_"c)
txtDestinationEncrypt.Text = S + strOutputEncrypt + ".encrypt"
btnEncrypt.Enabled = True
btnChangeEncrypt.Enabled = True

End If

End Sub
Private m_Alpha As Single = 0 Private m_DAlpha As Single = 0.05

Private Sub tmrDisplayFrame_Tick(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles tmrDisplayFrame.Tick
Dim bm1 As Bitmap = picSrc1.Image.Clone
Dim bm2 As Bitmap = picSrc2.Image.Clone

Dim image_attr As New imageAttributes


Dim cm As ColorMatrix
Dim bm As New Bitmap(bm1.Width, bm1.Height)
Dim gr As Graphics = Graphics.FromImage(bm)
Dim rect As Rectangle =
Rectangle.Round(bm1.GetBounds(GraphicsUnit.Pixel))

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm1, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

cm = New ColorMatrix(New Single()() { _


New Single() {1.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 1.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 1.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 0.0, 0.0}, _
New Single() {0.0, 0.0, 0.0, 1 - m_Alpha, 1.0}})
image_attr.SetColorMatrix(cm)
gr.DrawImage(bm2, rect, 0, 0, bm1.Width, bm2.Width,
GraphicsUnit.Pixel, image_attr)

picResult.Image = bm
picResult.Refresh()

m_Alpha += m_DAlpha
If m_Alpha > 1 Then
m_Alpha = 1
m_DAlpha *= -1
ElseIf m_Alpha < 0 Then
m_Alpha = 0
m_DAlpha *= -1
End If
End Sub

Private Sub btnBrowseDecrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnBrowseDecrypt.Click
OpenFileDialog.FileName = ""
OpenFileDialog.Title = "Choose a file to decrypt"
OpenFileDialog.InitialDirectory = "C:\"
OpenFileDialog.Filter = "Encrypted Files (*.encrypt) | *.encrypt"

If OpenFileDialog.ShowDialog = DialogResult.OK Then


strFileToDecrypt = OpenFileDialog.FileName
txtFileToDecrypt.Text = strFileToDecrypt
Dim iPosition As Integer = 0
Dim i As Integer = 0
While strFileToDecrypt.IndexOf("\"c, i) <> -1
iPosition = strFileToDecrypt.IndexOf("\"c, i)
i = iPosition + 1
End While

strOutputDecrypt = strFileToDecrypt.Substring(0,
strFileToDecrypt.Length - 8)
Dim S As String = strFileToDecrypt.Substring(0, iPosition + 1)
strOutputDecrypt = strOutputDecrypt.Substring((iPosition + 1))
txtDestinationDecrypt.Text = S +
strOutputDecrypt.Replace("_"c,"."c)
btnDecrypt.Enabled = True
btnChangeDecrypt.Enabled = True

End If
End Sub

Private Sub btnChangeEncrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnChangeEncrypt.Click
.
FolderBrowserDialog.Description = "Select a folder to place the
encrypted file in."
If FolderBrowserDialog.ShowDialog = DialogResult.OK Then
txtDestinationEncrypt.Text = FolderBrowserDialog.SelectedPath +
_
"\" + strOutputEncrypt + ".encrypt"
End If
End Sub

Private Sub btnChangeDecrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnChangeDecrypt.Click

FolderBrowserDialog.Description = "Select a folder for to place the


decrypted file in."
If FolderBrowserDialog.ShowDialog = DialogResult.OK Then
txtDestinationDecrypt.Text = FolderBrowserDialog.SelectedPath +
_
"\" +
strOutputDecrypt.Replace("_"c, "."c)
End If
End Sub

#End Region

#Region "6. Encrypt / Decrypt Buttons "

Private Sub btnEncrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnEncrypt.Click

If txtPassEncrypt.Text = "" OrElse txtConPassEncrypt.Text <>


txtPassEncrypt.Text Then

MsgBox("Please re-enter your password.",


MsgBoxStyle.Exclamation)
txtPassEncrypt.Text = ""
txtConPassEncrypt.Text = ""
Else

Dim bytKey As Byte()


Dim bytIV As Byte()
bytKey = CreateKey(txtPassEncrypt.Text)
bytIV = CreateIV(txtPassEncrypt.Text)
EncryptOrDecryptFile(strFileToEncrypt,
txtDestinationEncrypt.Text, _
bytKey, bytIV, CryptoAction.ActionEncrypt)

End If
End Sub

Private Sub btnDecrypt_Click(ByVal sender As System.Object, _


ByVal e As System.EventArgs) _
Handles btnDecrypt.Click
If txtConPassDecrypt.Text = txtPassDecrypt.Text Then
Dim bytKey As Byte()
Dim bytIV As Byte()
bytKey = CreateKey(txtPassDecrypt.Text)
bytIV = CreateIV(txtPassDecrypt.Text)
EncryptOrDecryptFile(strFileToDecrypt,
txtDestinationDecrypt.Text, _
bytKey, bytIV, CryptoAction.ActionDecrypt)
Else
MsgBox("Please re-enter your password.",
MsgBoxStyle.Exclamation)
txtPassDecrypt.Text = ""
txtConPassDecrypt.Text = ""
End If
End Sub

#End Region

End Class
STRINGCOMCRY.VB
Public Class stringcomcry

Private Sub cmd_Compress_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmd_Compress.Click

Dim CompStr As New


clsCompressedString(System.Text.Encoding.GetEncoding(Me.cbo_Encoding.Text.To
Lower))

If Me.chk_use_encryption.Checked Then
CompStr.Passphrase = Me.txt_Passphrase.Text
End If
If Me.chk_Use_Prefix_Suffix.Checked Then
CompStr.PrefixForCompressedString = Me.txt_Prefix.Text
CompStr.SuffixForCompressedString = Me.txt_Suffix.Text
End If
CompStr.UnCompressed = Me.txt_Uncompressed.Text
Me.txt_Compressed.Text = CompStr.Compressed

Me.txt_UnCompressed_Size.Text = CompStr.UnCompressed_Size.ToString
Me.txt_Compressed_Size.Text = CompStr.Compressed_Size.ToString
Me.txt_Compression_Ratio.Text = CompStr.Compression_Ratio.ToString

If CompStr.Compression_Ratio <= 1 And CompStr.Compression_Ratio > 0


Then
Me.pgb_Compressed_Percentage.Visible = True
Me.pgb_Compressed_Percentage.Maximum = 100
Me.pgb_Compressed_Percentage.Value =
Int(CompStr.Compression_Ratio * 100)
Else
Me.pgb_Compressed_Percentage.Visible = False
End If

End Sub

Private Sub cmd_Decompress_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles cmd_Decompress.Click

Dim CompStr As New


clsCompressedString(System.Text.Encoding.GetEncoding(Me.cbo_Encoding.Text.To
Lower))

If Me.chk_use_encryption.Checked Then
CompStr.Passphrase = Me.txt_Passphrase.Text
End If
If Me.chk_Use_Prefix_Suffix.Checked Then
CompStr.PrefixForCompressedString = Me.txt_Prefix.Text
CompStr.SuffixForCompressedString = Me.txt_Suffix.Text
End If
CompStr.Compressed = Me.txt_Compressed.Text
Me.txt_Uncompressed.Text = CompStr.UnCompressed

Me.txt_UnCompressed_Size.Text = CompStr.UnCompressed_Size.ToString
End Sub

Private Sub cmd_Clear_Uncompressed_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles cmd_Clear_Uncompressed.Click

Me.txt_Uncompressed.Text = String.Empty
Me.txt_UnCompressed_Size.Text = String.Empty

End Sub

Private Sub cmd_Clear_Compressed_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles cmd_Clear_Compressed.Click

Me.txt_Compressed.Text = String.Empty
Me.txt_Compressed_Size.Text = String.Empty
Me.txt_Compression_Ratio.Text = String.Empty

End Sub

Private Sub chk_Use_Prefix_Suffix_Click(ByVal sender As Object, ByVal e


As System.EventArgs) Handles chk_Use_Prefix_Suffix.Click

If Me.chk_Use_Prefix_Suffix.Checked Then
Me.txt_Prefix.Enabled = True
Me.txt_Suffix.Enabled = True
Me.txt_Prefix.BackColor = Color.White
Me.txt_Suffix.BackColor = Color.White
Else
Me.txt_Prefix.Enabled = False
Me.txt_Suffix.Enabled = False
Me.txt_Prefix.BackColor = Color.LightGray
Me.txt_Suffix.BackColor = Color.LightGray
End If
End Sub

Private Sub chk_use_encryption_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles chk_use_encryption.Click

If Me.chk_use_encryption.Checked Then
Me.txt_Passphrase.Enabled = True
Me.txt_Passphrase.BackColor = Color.White
Else
Me.txt_Passphrase.Enabled = False
Me.txt_Passphrase.BackColor = Color.LightGray
End If

End Sub

Private Sub txt_Uncompressed_TextChanged(ByVal sender As Object, ByVal e


As System.EventArgs) Handles txt_Uncompressed.TextChanged
Me.txt_UnCompressed_Size.Text =
Me.txt_Uncompressed.Text.Length.ToString
End Sub
End Class
TEXTFILECOMPRESS.VB
Imports System.IO
Imports System.IO.Compression

Public Class textfilecompress

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Dim file_name As String = Application.StartupPath
If file_name.EndsWith("\bin\Debug") Then
file_name = file_name.Substring(0,
file_name.LastIndexOf("\bin\Debug"))
End If
txtOriginalFile.Text = file_name & "\Form1.vb"
txtCompressedFile.Text = file_name & "\Form1.vb.gz"
txtDecompressedFile.Text = file_name & "\Form1.vb.ungz"
End Sub

Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnGo.Click
' Compress.
GZipFile(txtOriginalFile.Text, txtCompressedFile.Text)

' Decompress.
GUnzipFile(txtCompressedFile.Text, txtDecompressedFile.Text)

' Compare with the original.


CompareFiles(txtOriginalFile.Text, txtDecompressedFile.Text)
End Sub

' Compress a file.


Private Sub GZipFile(ByVal from_file As String, ByVal to_file As String)
Dim num_bytes As Long
Dim buf() As Byte

' Read the input file into a buffer.


Using from_stream As New FileStream(from_file, FileMode.Open,
FileAccess.Read, FileShare.Read)
num_bytes = from_stream.Length
ReDim buf(num_bytes - 1)
from_stream.Read(buf, 0, num_bytes)
from_stream.Close()
End Using ' from_stream

' Write the buffer to the output file.


Using to_stream As New FileStream(to_file, FileMode.Create,
FileAccess.Write, FileShare.Write)
Using zip_stream As New GZipStream(to_stream,
CompressionMode.Compress)
zip_stream.Write(buf, 0, num_bytes)
zip_stream.Close()
End Using ' zip_stream
to_stream.Close()
End Using ' to_stream
End Sub

' Decompress a file.


Private Sub GUnzipFile(ByVal from_file As String, ByVal to_file As
String)
Dim buf() As Byte

' Read the input file into a buffer.


Using from_stream As New FileStream(from_file, FileMode.Open,
FileAccess.Read, FileShare.Read)
Using zip_stream As New GZipStream(from_stream,
CompressionMode.Decompress)
Const CHUNK As Integer = 1024
Dim total_bytes_read As Integer = 0
Do
' Enlarge the buffer.
ReDim Preserve buf(total_bytes_read + CHUNK - 1)

' Read the next chunk.


Dim bytes_read As Integer = zip_stream.Read(buf,
total_bytes_read, CHUNK)
total_bytes_read += bytes_read

' See if we're done.


If bytes_read < CHUNK Then
' We're done. Make the buffer fit the data.
ReDim Preserve buf(total_bytes_read - 1)
Exit Do
End If
Loop

zip_stream.Close()
End Using ' zip_stream
from_stream.Close()
End Using ' from_stream

' Write the buffer into the output file.


Using to_stream As New FileStream(to_file, FileMode.Create,
FileAccess.Write, FileShare.Write)
to_stream.Write(buf, 0, buf.Length)
to_stream.Close()
End Using ' to_stream
End Sub

' Compare two files.


Private Sub CompareFiles(ByVal filename1 As String, ByVal filename2 As
String)
Dim file1() As Byte = My.Computer.FileSystem.ReadAllBytes(filename1)
Dim file2() As Byte = My.Computer.FileSystem.ReadAllBytes(filename2)

Dim files_different As Boolean = False


If file1.Length <> file2.Length Then
files_different = True
Else
For i As Integer = 0 To file1.Length - 1
If file1(i) <> file2(i) Then
files_different = True
Exit For
End If
Next i
End If

If files_different Then
MessageBox.Show("The files are different", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("files are compressed", "Success",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class
TEXTSTEGNO.VB

Imports System.Drawing

Public Class teststegano


'color algo
Shared user_rgb As Double = RGB(0, 0, 0) ' this will carry rgb lower
degree choosed by the user /for 0
Shared user_rgb_big As Double = RGB(0, 0, 1) ' this will carry rgb
bigger degree choosed by the user/for 1
''size algorithm
Shared user_size As Double = 10 ' this will carry size lower degree
choosed by the user
Shared Differential_f As Double = 0.2
Public Function SwapClipboardHtmlText(ByVal replacementHtmlText As
String) As String

Dim returnHtmlText As String = Nothing

If (Clipboard.ContainsText(TextDataFormat.Html)) Then
returnHtmlText = Clipboard.GetText(TextDataFormat.Html)
Clipboard.SetText(replacementHtmlText, TextDataFormat.Html)
End If

Return returnHtmlText

End Function
Public Sub SetText(ByVal Text As String)

' Dim returnHtmlText As String = Nothing

' If (Clipboard.ContainsText(TextDataFormat.Html)) Then


' returnHtmlText = Clipboard.GetText(TextDataFormat.Html)
Clipboard.SetText(Text, TextDataFormat.Html)
' End If

' Return returnHtmlText

End Sub

' Demonstrates SetData, ContainsData, and GetData.


Public Function SwapClipboardFormattedData( _
ByVal format As String, ByVal data As Object) As Object

Dim returnObject As Object = Nothing

If (Clipboard.ContainsData(format)) Then
returnObject = Clipboard.GetData(format)
Clipboard.SetData(format, data)
End If

Return returnObject

End Function
Public Sub encrypter1(ByRef loss_flag As Int16) ' 'radio 1 encryption
'if it returns 1 then there is error and should abort
loss_flag = 0
Dim text As String
text = TextBox1.Text.ToString + " "
Dim passw As String = ""
input("Enter Password To Protect Your Text", passw)
If passw = "" Then 'err handler for ugly passwords
MsgBox("Error ! You Didn,t Choose Any Password To Protect The
Message.")
loss_flag = 1
Exit Sub
ElseIf passw.Length < 4 Then
MsgBox("Error ! Password Is Too Short.")
loss_flag = 1
Exit Sub
End If

process_pass_with_tx(passw, text) ' this will encrypt the test by


the password
'this is done by generating a string from the password and this
string is tall enough to perform
' bit stream xor operation on all chares included in the message
text that we want to send.
'now we secured the text ,now we will try hide the encrypted text in
the text.

Dim amount As Double = text.Length

Dim tempt As String


tempt = TextBox2.Text

Dim amount2 As Double


amount2 = tempt.Length

Dim tre As Integer


Dim count As Long = 0
For tre = 0 To amount2 - 1
'If tempt.Substring(tre, 1).ToString <> " " Then ''remove
comments if you don,t want to allow spaces to be used
count = count + 1
' End If
Next ' i have now how many non spaces in fake message i have

If count <= ((amount * 8) + 64) Then ' (amount * 8) + 64) : 64 =8 *


8 :8 digits reserved to store text size
' 8 bits make one char ,and avoid spaces
'determine if the text is not big enough for text
MsgBox("Fake message is not big enough to carry your message",
MsgBoxStyle.Critical)
loss_flag = 1
Exit Sub
End If

Dim ba As bits_array
Dim sz As Long
Dim sz1, sz2, sz3, sz4 As Byte
Dim t As Double
sz = text.Length ' number of chars to encrypt

sz1 = Decimal.Remainder(sz, 100) ' take the lowest 2 digits of


it
t = sz / 100 'take the left numbers (all except lowest 2 digits)
sz = Decimal.Truncate(t) ''set size_variable to hold left numbers
(all except lowest 2 digits)

sz2 = Decimal.Remainder(sz, 100) ' repeat


t = sz / 100
sz = Decimal.Truncate(t)

sz3 = Decimal.Remainder(sz, 100) ' ' repeat


t = sz / 100
sz = Decimal.Truncate(t)

sz4 = Decimal.Remainder(sz, 100) ' will take final 2 digits, now


you can see: the maximum size of text is ( 99 99 99 99 )

'''''''''''''''''''''''''

''init globally this


Dim rt As New RichTextBox
tre = 0
''''''''''''''''''''''''
''''''''''''''''''''''''
Dim bigsize As Double
bigsize = Me.user_size + Me.Differential_f
MsgBox("The Used Differential Factor Is : " +
Me.Differential_f.ToString, MsgBoxStyle.Information)
'now we will convert sz1 to bits array and store it in the first
'after it we will do the sz2 and then sz3 and then sz4..
'the coming 4 for loops are used for that
Dim i, j, m
i = 0
j = 1
ba.Initialize()
byte_to_bits(sz1, ba)

For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
rt.Font = New Font(TextBox2.Font.Name, (bigsize),
TextBox2.Font.Style, TextBox2.Font.Unit)
Else
rt.Font = New Font(TextBox2.Font.Name, Me.user_size,
TextBox2.Font.Style, TextBox2.Font.Unit)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m

ba.Initialize()
byte_to_bits(sz2, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
rt.Font = New Font(TextBox2.Font.Name, (bigsize),
TextBox2.Font.Style, TextBox2.Font.Unit)
Else
rt.Font = New Font(TextBox2.Font.Name, Me.user_size,
TextBox2.Font.Style, TextBox2.Font.Unit)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
ba.Initialize()
byte_to_bits(sz3, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
rt.Font = New Font(TextBox2.Font.Name, (bigsize),
TextBox2.Font.Style, TextBox2.Font.Unit)
Else
rt.Font = New Font(TextBox2.Font.Name, Me.user_size,
TextBox2.Font.Style, TextBox2.Font.Unit)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
ba.Initialize()
byte_to_bits(sz4, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
rt.Font = New Font(TextBox2.Font.Name, (bigsize),
TextBox2.Font.Style, TextBox2.Font.Unit)
Else
rt.Font = New Font(TextBox2.Font.Name, Me.user_size,
TextBox2.Font.Style, TextBox2.Font.Unit)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
'MsgBox(sz1.ToString)
' MsgBox(sz2.ToString)
' MsgBox(sz3.ToString)
' MsgBox(sz4.ToString)
'MsgBox(sz)
'''' we have just stored the size of the text
'now we will store real message's text itself

Dim cnt As Long


For cnt = 0 To text.Length - 1
sz4 = 0
sz4 = Asc(text.Substring(cnt, 1)) 'take one char /byte
ba.Initialize()
byte_to_bits(sz4, ba) 'change it to bits
For m = 0 To 7 'store bits in fake mes
''''''''''''''''''
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
rt.Font = New Font(TextBox2.Font.Name, (bigsize),
TextBox2.Font.Style, TextBox2.Font.Unit)
Else
rt.Font = New Font(TextBox2.Font.Name, Me.user_size,
TextBox2.Font.Style, TextBox2.Font.Unit)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m

Next cnt
''now commplete the usless rest of text
Dim rest As Long
For rest = tre + 1 To tempt.Length - 1
rt.Clear()
rt.Font = New Font(TextBox2.Font.Name, (Me.user_size),
TextBox2.Font.Style, TextBox2.Font.Unit)
rt.Text = tempt.Substring(rest, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()
Next
rt.Dispose()
End Sub
Public Sub encrypter2(ByRef loss_flag As Int16)
loss_flag = 0
Dim text As String
text = TextBox1.Text.ToString + " "
Dim passw As String = ""
input("Enter Password To Protect Your Text", passw)
If passw = "" Then 'err handler for ugly passwords
MsgBox("Error ! You Didn,t Choose Any Password To Protect The
Message.")
loss_flag = 1
Exit Sub
ElseIf passw.Length < 4 Then
MsgBox("Error ! Password Is Too Short.")
loss_flag = 1
Exit Sub
End If

process_pass_with_tx(passw, text) ' this will encrypt the test by


the password
'this is done by generating a string from the password and this
string is tall enough to perform
' bit stream xor operation on all chares included in the message
text that we want to send.
'now we secured the text ,now we will try hide the encrypted text in
the text.

Dim amount As Double = text.Length

Dim tempt As String


tempt = TextBox2.Text
Dim amount2 As Double
amount2 = tempt.Length

Dim tre As Integer


Dim count As Long = 0
For tre = 0 To amount2 - 1
'If tempt.Substring(tre, 1).ToString <> " " Then ' remove
comments if you don,t want spaces
count = count + 1
' End If
Next ' i have now how many non spaces in fake message i have

If count <= ((amount * 8) + 64) Then ' (amount * 8) + 64) : 64 =8 *


8 :8 digits reserved to store text size
' 8 bits make one char ,and avoid spaces
'determine if the text is not big enough for text
MsgBox("Fake message is not big enough to carry your message",
MsgBoxStyle.Critical)
loss_flag = 1
Exit Sub
End If
MsgBox("Selected Color /numeric value/ is : " +
Me.user_rgb.ToString, MsgBoxStyle.Information)
Dim ba As bits_array
Dim sz As Long
Dim sz1, sz2, sz3, sz4 As Byte
Dim t As Double
Dim Color As Color
sz = text.Length ' number of chars to encrypt

sz1 = Decimal.Remainder(sz, 100) ' take the lowest 2 digits of


it
t = sz / 100 'take the left numbers (all except lowest 2 digits)
sz = Decimal.Truncate(t) ''set size_variable to hold left numbers
(all except lowest 2 digits)

sz2 = Decimal.Remainder(sz, 100) ' repeat


t = sz / 100
sz = Decimal.Truncate(t)

sz3 = Decimal.Remainder(sz, 100) ' ' repeat


t = sz / 100
sz = Decimal.Truncate(t)

sz4 = Decimal.Remainder(sz, 100) ' will take final 2 digits, now


you can see: the maximum size of text is ( 99 99 99 99 )

'''''''''''''''''''''''''

''init globally this


Dim rt As New RichTextBox
tre = 0
''''''''''''''''''''''''
''''''''''''''''''''''''

'now we will convert sz1 to bits array and store it in the first
'after it we will do the sz2 and then sz3 and then sz4..
'the coming 4 for loops are used for that
Dim i, j, m
i = 0
j = 1
ba.Initialize()
byte_to_bits(sz1, ba)

For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then

Color = ColorTranslator.FromWin32(Me.user_rgb_big)
rt.ForeColor = Color
Else

Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m

ba.Initialize()
byte_to_bits(sz2, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then

Color = ColorTranslator.FromWin32(Me.user_rgb_big)
rt.ForeColor = Color
Else
Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
End If
tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
ba.Initialize()
byte_to_bits(sz3, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
Color = ColorTranslator.FromWin32(Me.user_rgb_big)
rt.ForeColor = Color
Else
Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
ba.Initialize()
byte_to_bits(sz4, ba)
For m = 0 To 7 '''''''''''''''''' 1
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
Color = ColorTranslator.FromWin32(Me.user_rgb_big)
rt.ForeColor = Color
Else
Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m
' MsgBox(sz1.ToString)
'MsgBox(sz2.ToString)
' MsgBox(sz3.ToString)
' MsgBox(sz4.ToString)
' MsgBox(amount)
'''' we have just stored the size of the text
'now we will store real message's text itself

Dim cnt As Long


For cnt = 0 To text.Length - 1
sz4 = 0
sz4 = Asc(text.Substring(cnt, 1)) 'take one char /byte
ba.Initialize()
byte_to_bits(sz4, ba) 'change it to bits
For m = 0 To 7 'store bits in fake mes
''''''''''''''''''
i = i + 1

'''''''''''''''''''''''''
rt.Text = ""
' set the size according to my bit
If ba.bits(m) = True Then
Color = ColorTranslator.FromWin32(Me.user_rgb_big)
rt.ForeColor = Color
' MsgBox(Color.ToArgb.ToString)
Else
Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
'MsgBox(Color.ToArgb.ToString)
End If

tre = tre + 1
rt.Text = tempt.Substring(tre, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()

''''''''''''''''''''''''''
Next m

Next cnt
''now commplete the usless rest of text
Dim rest As Long
For rest = tre + 1 To tempt.Length - 1
rt.Clear()
Color = ColorTranslator.FromWin32(Me.user_rgb)
rt.ForeColor = Color
rt.Text = tempt.Substring(rest, 1)
rt.SelectAll()
Clipboard.SetText(rt.SelectedRtf, TextDataFormat.Rtf)
RichTextBox1.Paste()
Next
rt.Dispose()
End Sub
Public Sub decrypter1(ByRef errflag As Boolean)
errflag = False
TextBox1.Text = ""

Dim tm As String = RichTextBox1.Text


Dim cont As Double = -1
' Dim rt As New RichTextBox
Dim ba As bits_array

ba.Initialize()
Dim sz As Long
Dim sz1, sz2, sz3, sz4 As Byte
Dim m As Long

For m = 0 To 7
' rt.Clear()
cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionFont.Size = Me.user_size Then
ba.bits(m) = False
Else
ba.bits(m) = True
End If

Next m
bits_to_byte(sz1, ba)
ba.Initialize()
' MsgBox(sz1.ToString)
For m = 0 To 7

cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionFont.Size = Me.user_size Then
ba.bits(m) = False
Else
ba.bits(m) = True
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz2, ba)
ba.Initialize()
' MsgBox(sz2.ToString)
For m = 0 To 7

cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionFont.Size = Me.user_size Then
ba.bits(m) = False
Else
ba.bits(m) = True
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz3, ba)
ba.Initialize()
' MsgBox(sz3.ToString)
For m = 0 To 7
cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionFont.Size = Me.user_size Then
ba.bits(m) = False
Else
ba.bits(m) = True
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz4, ba)
ba.Initialize()

sz = sz1 + 100 * sz2 + 10000 * sz3 + sz4 * 1000000


If sz = 0 Or sz >= (255 * 1010100) Then
MsgBox("Error: Font Doesn,t Support This Size")
errflag = True
Exit Sub
End If
MsgBox("The Used Differential Factor Is : " +
Me.Differential_f.ToString, MsgBoxStyle.Information)
'MsgBox(sz)
' Exit Sub
'now we collected size of text so we start collecting text
''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Long
Dim output As String = ""
For i = 1 To sz
ba.Initialize()
For m = 0 To 7
cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionFont.Size = Me.user_size Then
ba.bits(m) = False
Else
ba.bits(m) = True
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz1, ba)
output = output + Chr(sz1).ToString
Next i
'[][][]
' MsgBox(output.ToString)
Dim passw As String = ""
input("Enter Password To Decrypt Your Text", passw)

If passw = "" Then


MsgBox("User Canceled.")
errflag = True
Exit Sub
ElseIf passw.Length < 4 Then
MsgBox("Error ! Password Is Too Short.")
errflag = True
Exit Sub
End If

process_pass_with_tx(passw, output)
' MsgBox(output.ToString)
Dim je As Long
je = output.Length - 1
output = output.Substring(0, je)
TextBox1.Text = output

End Sub
Public Sub decrypter2(ByRef errflag As Boolean)
errflag = False
TextBox1.Text = ""
MsgBox("Selected Color /numeric value/ is : " +
Me.user_rgb.ToString, MsgBoxStyle.Information)
Dim tm As String = RichTextBox1.Text
Dim cont As Double = -1
' Dim rt As New RichTextBox
Dim color As Color
Dim ba As bits_array

ba.Initialize()
Dim sz As Long
Dim sz1, sz2, sz3, sz4 As Byte
Dim m As Long

For m = 0 To 7
' rt.Clear()
cont = cont + 1
RichTextBox1.Select(cont, 1)
' MsgBox(RichTextBox1.SelectionColor.ToArgb.ToString)
' MsgBox(Me.user_rgb_big.ToString + " <-big_ normal->" +
Me.user_rgb.ToString)

If RichTextBox1.SelectionColor =
ColorTranslator.FromWin32(Me.user_rgb_big) Then
ba.bits(m) = True
Else
ba.bits(m) = False
End If

Next m
bits_to_byte(sz1, ba)
ba.Initialize()

For m = 0 To 7

cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionColor =
ColorTranslator.FromWin32(Me.user_rgb_big) Then
ba.bits(m) = True
Else
ba.bits(m) = False
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz2, ba)
ba.Initialize()
' MsgBox(sz2.ToString)
For m = 0 To 7

cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionColor =
ColorTranslator.FromWin32(Me.user_rgb_big) Then
ba.bits(m) = True
Else
ba.bits(m) = False
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz3, ba)
ba.Initialize()
' MsgBox(sz3.ToString)
For m = 0 To 7

cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionColor =
ColorTranslator.FromWin32(Me.user_rgb_big) Then
ba.bits(m) = True
Else
ba.bits(m) = False
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz4, ba)
ba.Initialize()

sz = sz1 + 100 * sz2 + 10000 * sz3 + sz4 * 1000000


If sz = 0 Or sz >= (255 * 1010100) Then
MsgBox("Error: Font Doesn,t Support This Color")
errflag = True
Exit Sub
End If

'now we collected size of text so we start collecting text


''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''
Dim i As Long
Dim output As String = ""
For i = 1 To sz
ba.Initialize()
For m = 0 To 7
cont = cont + 1
RichTextBox1.Select(cont, 1)
If RichTextBox1.SelectionColor =
ColorTranslator.FromWin32(Me.user_rgb_big) Then
ba.bits(m) = True
Else
ba.bits(m) = False
End If
''' RichTextBox1.Refresh()
Next m
bits_to_byte(sz1, ba)
output = output + Chr(sz1).ToString
Next i
'[][][]
' MsgBox(output.ToString)
Dim passw As String = ""
input("Enter Password To Decrypt Your Text", passw)

If passw = "" Then


MsgBox("User Canceled.")
errflag = True
Exit Sub
ElseIf passw.Length < 4 Then
MsgBox("Error ! Password Is Too Short.")
errflag = True
Exit Sub
End If

process_pass_with_tx(passw, output)
' MsgBox(output.ToString)
Dim je As Long
je = output.Length - 1
output = output.Substring(0, je)
TextBox1.Text = output
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

If RadioButton1.Checked = False And RadioButton2.Checked = False


Then
MsgBox("You didn,t Select any mode !")
Exit Sub
End If
TextBox2.Text = " " + TextBox2.Text ' to stop runtime err /loss of
first char in fake text
''init
RichTextBox1.Clear()
''''''
If TextBox1.Text.Trim = "" Then
MsgBox("REAL MESSAGE is empty so what is the point?".ToUpper,
MsgBoxStyle.Exclamation)
Exit Sub
End If

'' remember to avoid spaces <<<<<<<<<<<


'' color change mode start
If RadioButton2.Checked = True Then

Dim flg2 As Int16


Call encrypter2(flg2)
If flg2 = 0 Then
MsgBox("Done")
End If
Exit Sub

End If
''''''''''''color change mode finish
'''''''''''''''''''''''''''''''''''''''''

'here we deal with font size mode ':: radio1.checked = true


Dim flg As Int16
Call encrypter1(flg)
If flg = 0 Then
MsgBox("Done")
MsgBox("Please make sure that the font you used supports the
size and the used Differential Factor by trying to decrypt it here before
you send it".ToUpper, MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, _
ByVal e As System.EventArgs)

' Cast the sender object back to a ComboBox.


Dim ComboBox1 As ComboBox = CType(sender, ComboBox)

' Retrieve the selected item.


Dim selectedString As String = CType(ComboBox1.SelectedItem, String)

' Convert it to lowercase.


selectedString = selectedString.ToLower()

' Declare the current size.


Dim currentSize As Single

''''''''''''''radio button 2 colr start ***************


Select Case selectedString

' If Bigger is selected, get the current size from the


' Size property and increase it. Reset the font to the
' new size, using the current unit.
Case "bigger"
currentSize = Label1.Font.Size
'currentSize += 1.0F
currentSize = 10.1
Label1.Font = New Font(Label1.Font.Name, currentSize,
Label1.Font.Style, Label1.Font.Unit)
MsgBox(Label1.Font.Size)

' If Smaller is selected, get the current size, in points,


' and decrease it by 1. Reset the font with the new size
' in points.
Case "smaller"
currentSize = Label1.Font.SizeInPoints
' currentSize -= 1.0F
currentSize = 10
Label1.Font = New Font(Label1.Font.Name, currentSize,
Label1.Font.Style)
MsgBox(Label1.Font.Size)
End Select
'''''''''''''radio button2 colr end *******************

' Switch on the selected item.


Select Case selectedString

' If Bigger is selected, get the current size from the


' Size property and increase it. Reset the font to the
' new size, using the current unit.
Case "bigger"
currentSize = Label1.Font.Size
'currentSize += 1.0F
currentSize = 10.1
Label1.Font = New Font(Label1.Font.Name, currentSize, _
Label1.Font.Style, Label1.Font.Unit)
MsgBox(Label1.Font.Size)

' If Smaller is selected, get the current size, in points,


' and decrease it by 1. Reset the font with the new size
' in points.
Case "smaller"
currentSize = Label1.Font.SizeInPoints
' currentSize -= 1.0F
currentSize = 10
Label1.Font = New Font(Label1.Font.Name, currentSize, _
Label1.Font.Style)
MsgBox(Label1.Font.Size)
End Select
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)

End Sub
Private Sub RenderText6(ByVal e As PaintEventArgs)
Dim flags As TextFormatFlags = TextFormatFlags.Bottom Or _
TextFormatFlags.EndEllipsis
TextRenderer.DrawText(e.Graphics, _
"This is some text that will be clipped at the end.", _
Me.Font, New Rectangle(10, 10, 100, 50), SystemColors.ControlText,
flags)

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
GroupBox1.Visible = False
GroupBox2.Visible = True
Dim inp As String
inp = InputBox("Enter the font size of your message", "AJ
Stega", "10")
Dim temp As Double

If inp = "" Then GoTo ff


On Error GoTo ff2
temp = CType(inp, Double)
On Error GoTo ff2
If inp = "" Then GoTo ff

If temp < 0 Or temp >= 72 Then


MsgBox("Out of rang , This value may cause unexpected
behaviour")
RadioButton1.Checked = False
Exit Sub
End If

Me.user_size = CType(inp, Double)


On Error GoTo ff2

Me.info.Text = "Selected Size : " + Me.user_size.ToString


info.ForeColor = Color.Peru
info.Visible = True

End If
Exit Sub
ff:
MsgBox("User Cancelled")
GroupBox2.Visible = False
RadioButton1.Checked = False
Exit Sub
ff2:
MsgBox("Invalid value !")
GroupBox2.Visible = False
RadioButton1.Checked = False
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
If RadioButton1.Checked = False And RadioButton2.Checked = False
Then
MsgBox("You didn,t Select any mode !")
Exit Sub
End If
If RichTextBox1.Text = "" Then
MsgBox("you need to paste received message in output or use
(load from file) to open received rtf file".ToUpper,
MsgBoxStyle.Exclamation)
Exit Sub
End If

If RadioButton1.Checked = True Then 'size


Dim d As Boolean = False
decrypter1(d)
If d = False Then
MsgBox("Done")
End If
End If

If RadioButton2.Checked = True Then 'color


Dim d3 As Boolean = False
decrypter2(d3)
If d3 = False Then
MsgBox("Done")
End If
End If

End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Dim inp As String
GroupBox1.Visible = True
GroupBox2.Visible = False
Me.user_rgb = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), CType(TextBox5.Text, Integer))
ComboBox1.SelectedIndex = 1
'''''''''''''''''''''''''''''''''
Dim tempr As Integer
If Me.ComboBox1.SelectedIndex = 0 Then 'red
tempr = (CType(TextBox3.Text, Integer) + 1)
Me.user_rgb_big = RGB(tempr, CType(TextBox4.Text, Integer),
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 1 Then 'green
tempr = (CType(TextBox4.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer), tempr,
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 2 Then 'blue
tempr = (CType(TextBox5.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), tempr)
End If
''''''''''''''''''''''''''''''''
Dim mColor As Color = ColorTranslator.FromWin32(Me.user_rgb)
Me.info.Text = "This Is Selected Color "
info.ForeColor = mColor
info.Visible = True
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox3.TextChanged
Dim inp As String

On Error GoTo ba
Dim tt = CType(TextBox3.Text, Integer)
On Error GoTo ba

If tt < 0 Or tt > 254 Then


MsgBox("Invalid input , Out of rang [0,254] !")
TextBox3.Text = 0
Exit Sub
End If

On Error GoTo ba
Me.user_rgb = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), CType(TextBox5.Text, Integer))
On Error GoTo ba
Dim tempr As Integer
If Me.ComboBox1.SelectedIndex = 0 Then 'red
tempr = (CType(TextBox3.Text, Integer) + 1)
Me.user_rgb_big = RGB(tempr, CType(TextBox4.Text, Integer),
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 1 Then 'green
tempr = (CType(TextBox4.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer), tempr,
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 2 Then 'blue
tempr = (CType(TextBox5.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), tempr)
End If
On Error GoTo ba

Dim mColor As Color = ColorTranslator.FromWin32(Me.user_rgb)


On Error GoTo ba
Me.info.Text = "This Is Selected Color "
info.ForeColor = mColor
' info.Visible = True
Exit Sub
ba:
TextBox3.Text = "0"
End Sub

Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles TextBox4.TextChanged
Dim inp As String

On Error GoTo ba
Dim tt = CType(TextBox4.Text, Integer)
On Error GoTo ba

If tt < 0 Or tt > 254 Then


MsgBox("Invalid input , Out of rang [0,254] !")
TextBox4.Text = 0
Exit Sub
End If

On Error GoTo ba
Me.user_rgb = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), CType(TextBox5.Text, Integer))
On Error GoTo ba
Dim tempr As Integer
If Me.ComboBox1.SelectedIndex = 0 Then 'red
tempr = (CType(TextBox3.Text, Integer) + 1)
Me.user_rgb_big = RGB(tempr, CType(TextBox4.Text, Integer),
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 1 Then 'green
tempr = (CType(TextBox4.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer), tempr,
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 2 Then 'blue
tempr = (CType(TextBox5.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), tempr)
End If
On Error GoTo ba

Dim mColor As Color = ColorTranslator.FromWin32(Me.user_rgb)


On Error GoTo ba
Me.info.Text = "This Is Selected Color "
info.ForeColor = mColor
' info.Visible = True
Exit Sub
ba:
TextBox4.Text = "0"
End Sub

Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles TextBox5.TextChanged
Dim inp As String

On Error GoTo ba
Dim tt = CType(TextBox5.Text, Integer)
On Error GoTo ba

If tt < 0 Or tt > 254 Then


MsgBox("Invalid input , Out of rang [0,254] !")
TextBox5.Text = 0
Exit Sub
End If

On Error GoTo ba
Me.user_rgb = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), CType(TextBox5.Text, Integer))
On Error GoTo ba
Dim tempr As Integer
If Me.ComboBox1.SelectedIndex = 0 Then 'red
tempr = (CType(TextBox3.Text, Integer) + 1)
Me.user_rgb_big = RGB(tempr, CType(TextBox4.Text, Integer),
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 1 Then 'green
tempr = (CType(TextBox4.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer), tempr,
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 2 Then 'blue
tempr = (CType(TextBox5.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), tempr)
End If
On Error GoTo ba

Dim mColor As Color = ColorTranslator.FromWin32(Me.user_rgb)


On Error GoTo ba
Me.info.Text = "This Is Selected Color "
info.ForeColor = mColor
' info.Visible = True
Exit Sub
ba:
TextBox5.Text = "0"
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles TextBox1.TextChanged
Dim jj As Long
jj = (TextBox1.Text.Length) * 8 + 64 + 9 '64 size reserved ' 9 = 8+1
'8 for space we always add to text
'at transmission to make sure no one is playing with the text after
transmission 'last 1 is to make it bigger when comparing sizes in algo to
evaluate fake message size
On Error Resume Next
Label11.Text = "Real Message: Required Capacity(" + jj.ToString +
")"
On Error Resume Next
End Sub

Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs)

End Sub

Private Sub TextBox6_TextChanged_1(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles TextBox6.TextChanged
On Error GoTo outr
Me.Differential_f = CType(TextBox6.Text.ToString, Double)
If Me.Differential_f < 0.2 Then GoTo cant
On Error GoTo outr
Exit Sub
outr:
TextBox6.Text = "0.2"
Me.Differential_f = 0.2
MsgBox("Invalid Input")
Exit Sub
cant:
TextBox6.Text = "0.2"
Me.Differential_f = 0.2
MsgBox("Differential Factor Must be >= 0.2 ")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
End
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
Me.WindowState = FormWindowState.Minimized
End Sub

Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
Dim tempr As Integer
If Me.ComboBox1.SelectedIndex = 0 Then 'red
tempr = (CType(TextBox3.Text, Integer) + 1)
Me.user_rgb_big = RGB(tempr, CType(TextBox4.Text, Integer),
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 1 Then 'green
tempr = (CType(TextBox4.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer), tempr,
CType(TextBox5.Text, Integer))
ElseIf Me.ComboBox1.SelectedIndex = 2 Then 'blue
tempr = (CType(TextBox5.Text, Integer) + 1)
Me.user_rgb_big = RGB(CType(TextBox3.Text, Integer),
CType(TextBox4.Text, Integer), tempr)
End If
End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles TextBox2.TextChanged
On Error Resume Next
Label2.Text = "Fake Message: Capacity(" +
TextBox2.Text.Length.ToString + ")"
On Error Resume Next
End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label2.Click

End Sub

Private Sub Label11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label11.Click

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button8.Click
RadioButton1.Checked = False
RadioButton2.Checked = False
GroupBox2.Visible = False
GroupBox1.Visible = False
info.Visible = False
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
TextBox1.SelectAll()
TextBox1.Paste()
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
TextBox1.Clear()
End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
TextBox2.SelectAll()
TextBox2.Paste()
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
TextBox2.Clear()
End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
RichTextBox1.SelectAll()
RichTextBox1.Paste()
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
RichTextBox1.Clear()
End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
If RichTextBox1.Text = "" Then
MsgBox("No Text to copy".ToUpper)
Exit Sub
End If
Clipboard.Clear()
RichTextBox1.SelectAll()
Clipboard.SetText(RichTextBox1.SelectedRtf, TextDataFormat.Rtf)
MsgBox("Now you can paste your message in *.doc file or MailMessage
body ")

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
OpenFileDialog1.Title = "Select RTF File"
OpenFileDialog1.FileName = ""
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel
Then Exit Sub
On Error GoTo ff
RichTextBox1.LoadFile(OpenFileDialog1.FileName)
If OpenFileDialog1.FileName = "" Or
System.IO.File.Exists(OpenFileDialog1.FileName) = False Then
GoTo ff
End If
On Error GoTo ff
MsgBox("Done")
Exit Sub
ff:
MsgBox(Err.Description)
End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
SaveFileDialog1.FileName = ""
If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel
Then Exit Sub
On Error GoTo ff
If SaveFileDialog1.FileName.ToString.EndsWith(".rtf") Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName)
Else
RichTextBox1.SaveFile(SaveFileDialog1.FileName + ".rtf")
End If

On Error GoTo ff
MsgBox("Done")
Exit Sub
ff:
MsgBox(Err.Description)
End Sub

End Class
TRANSPOSITION.VB
Public Class Transposition

Private Sub CmdEncrypt_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CmdEncrypt.Click
'>>> validation
If Val(TxtRow.Text) < 1 Then
MsgBox("Row value should be more than 0.",
MsgBoxStyle.Exclamation)
TxtRow.Focus()
Exit Sub
End If

If Val(TxtColumn.Text) < 1 Then


MsgBox("Column value should be more than 0.",
MsgBoxStyle.Exclamation)
TxtColumn.Focus()
Exit Sub
End If

TxtCipherText.Text = MessageTransposition(TxtPlainText.Text, True)


End Sub

Private Function MessageTransposition(ByVal StrDataIn As String, ByVal


ED As Boolean) As String

'>>> if nedd xor, use this code


Dim XORCode As Integer
XORCode = 165

Dim IndR As Integer


Dim IndC As Integer

IndR = Val(TxtRow.Text)
IndC = Val(TxtColumn.Text)
'>>> create the array
Dim DataArray(IndR, IndC) As String
Dim i, j As Integer
Dim r, c As Integer
Dim StrOut As String
StrOut = ""
i = 1
'>>> loop to total length
While i <= StrDataIn.Length

'>>> clear the array


For r = 0 To IndR
For c = 0 To IndC
DataArray(r, c) = Chr(1)
Next
Next

'>>> check the loop last postion


Dim LastPos As Integer
If i + (IndR * IndC) - 1 <= StrDataIn.Length Then
LastPos = i + (IndR * IndC) - 1
Else
LastPos = StrDataIn.Length
End If

'>>> store strdatain into array character by character


'>>> initial the array indexer
r = 0
c = 0
For j = i To LastPos

'>>> check if need to XOR the character


If ChkXOR.Checked = True Then
Dim TempChar As String
TempChar = Mid(StrDataIn, j, 1)
DataArray(r, c) = Chr(Asc(TempChar) Xor XORCode)
Else
DataArray(r, c) = Mid(StrDataIn, j, 1)
End If

c = c + 1

'>>> reset the array indexer


If r > IndR - 1 Then
r = 0
c = 0
End If
If c > IndC - 1 Then
c = 0
r = r + 1
End If
Next

'>>> add array value to string coulumn nad row wise


If ED = True Then
For c = 0 To IndC - 1
For r = 0 To IndR - 1
StrOut = StrOut & DataArray(r, c)
Next
Next
Else
'>>> decrypt logics
Dim StrTemp As String
StrTemp = ""
Dim p, p1 As Integer
p = 1
p1 = 1
For r = 0 To IndR - 1
For c = 0 To IndC - 1
StrTemp = StrTemp & DataArray(r, c)
Next
Next
While p <= StrTemp.Length
'>>> replace array filling character
'>>> check if it is xor
If ChkXOR.Checked = True Then
StrOut = StrOut & Replace(Mid(StrTemp, p1, 1),
Chr(Asc(Chr(1)) Xor XORCode), "")
Else
StrOut = StrOut & Replace(Mid(StrTemp, p1, 1),
Chr(1), "")
End If

p = p + 1

'>>> increment position by row


p1 = p1 + IndR
If p1 > StrTemp.Length Then
p1 = p1 - StrTemp.Length + 1
End If
End While
End If
i = i + IndR * IndC
End While

MessageTransposition = StrOut

End Function

Private Sub CmdDEcrypt_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CmdDEcrypt.Click

'>>> validation
If Val(TxtRow.Text) < 1 Then
MsgBox("Row value should be more than 0.",
MsgBoxStyle.Exclamation)
TxtRow.Focus()
Exit Sub
End If

If Val(TxtColumn.Text) < 1 Then


MsgBox("Column value should be more than 0.",
MsgBoxStyle.Exclamation)
TxtColumn.Focus()
Exit Sub
End If

TxtPlainText.Text = MessageTransposition(TxtCipherText.Text, False)

End Sub

End Class
PIC_KEYVB.VB
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.IO
Imports System.Text

''' <summary>
'''
''' </summary>
Public Class pic_keyvb
Inherits System.Windows.Forms.Form

Public Sub New()

InitializeComponent()
End Sub

''' <summary>Cleanup</summary>
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

#Region "Windows Form Designer generated code"


''' <summary>
'''
''' </summary>
Private Sub InitializeComponent()
Me.grpPicture = New System.Windows.Forms.GroupBox
Me.label2 = New System.Windows.Forms.Label
Me.txtImageFile = New System.Windows.Forms.TextBox
Me.btnImageFile = New System.Windows.Forms.Button
Me.txtKeyFile = New System.Windows.Forms.TextBox
Me.rdoKeyText = New System.Windows.Forms.RadioButton
Me.grpKey = New System.Windows.Forms.GroupBox
Me.txtKeyText = New System.Windows.Forms.TextBox
Me.btnKeyFile = New System.Windows.Forms.Button
Me.rdoKeyFile = New System.Windows.Forms.RadioButton
Me.btnHide = New System.Windows.Forms.Button
Me.btnExtract = New System.Windows.Forms.Button
Me.tabControl1 = New System.Windows.Forms.TabControl
Me.tabPage1 = New System.Windows.Forms.TabPage
Me.grpMessage = New System.Windows.Forms.GroupBox
Me.rdoMessageText = New System.Windows.Forms.RadioButton
Me.txtMessageFile = New System.Windows.Forms.TextBox
Me.txtMessageText = New System.Windows.Forms.TextBox
Me.btnMessage = New System.Windows.Forms.Button
Me.rdoMessageFile = New System.Windows.Forms.RadioButton
Me.btnSaveBitmap = New System.Windows.Forms.Button
Me.chkGrayscale = New System.Windows.Forms.CheckBox
Me.tabPage2 = New System.Windows.Forms.TabPage
Me.groupBox3 = New System.Windows.Forms.GroupBox
Me.label1 = New System.Windows.Forms.Label
Me.txtExtractedMsgFile = New System.Windows.Forms.TextBox
Me.txtExtractedMsgText = New System.Windows.Forms.TextBox
Me.btnExtractedMsgFile = New System.Windows.Forms.Button
Me.label3 = New System.Windows.Forms.Label
Me.picImage = New System.Windows.Forms.PictureBox
Me.grpPicture.SuspendLayout()
Me.grpKey.SuspendLayout()
Me.tabControl1.SuspendLayout()
Me.tabPage1.SuspendLayout()
Me.grpMessage.SuspendLayout()
Me.tabPage2.SuspendLayout()
Me.groupBox3.SuspendLayout()
CType(Me.picImage,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'grpPicture
'
Me.grpPicture.Controls.Add(Me.label2)
Me.grpPicture.Controls.Add(Me.txtImageFile)
Me.grpPicture.Controls.Add(Me.picImage)
Me.grpPicture.Controls.Add(Me.btnImageFile)
Me.grpPicture.Location = New System.Drawing.Point(13, 14)
Me.grpPicture.Name = "grpPicture"
Me.grpPicture.Size = New System.Drawing.Size(400, 256)
Me.grpPicture.TabIndex = 0
Me.grpPicture.TabStop = False
Me.grpPicture.Text = "Carrier Bitmap (no image loaded)"
'
'label2
'
Me.label2.Location = New System.Drawing.Point(13, 28)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(54, 20)
Me.label2.TabIndex = 5
Me.label2.Text = "Filename"
'
'txtImageFile
'
Me.txtImageFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtImageFile.Location = New System.Drawing.Point(73, 28)
Me.txtImageFile.Name = "txtImageFile"
Me.txtImageFile.Size = New System.Drawing.Size(247, 20)
Me.txtImageFile.TabIndex = 0
'
'btnImageFile
'
Me.btnImageFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnImageFile.Location = New System.Drawing.Point(320, 28)
Me.btnImageFile.Name = "btnImageFile"
Me.btnImageFile.Size = New System.Drawing.Size(67, 20)
Me.btnImageFile.TabIndex = 1
Me.btnImageFile.Text = "Browse..."
Me.btnImageFile.UseVisualStyleBackColor = False
'
'txtKeyFile
'
Me.txtKeyFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtKeyFile.Location = New System.Drawing.Point(93, 21)
Me.txtKeyFile.Name = "txtKeyFile"
Me.txtKeyFile.Size = New System.Drawing.Size(227, 20)
Me.txtKeyFile.TabIndex = 1
'
'rdoKeyText
'
Me.rdoKeyText.Checked = True
Me.rdoKeyText.Location = New System.Drawing.Point(13, 49)
Me.rdoKeyText.Name = "rdoKeyText"
Me.rdoKeyText.Size = New System.Drawing.Size(67, 20)
Me.rdoKeyText.TabIndex = 3
Me.rdoKeyText.TabStop = True
Me.rdoKeyText.Text = "Text"
'
'grpKey
'
Me.grpKey.Controls.Add(Me.rdoKeyText)
Me.grpKey.Controls.Add(Me.txtKeyFile)
Me.grpKey.Controls.Add(Me.txtKeyText)
Me.grpKey.Controls.Add(Me.btnKeyFile)
Me.grpKey.Controls.Add(Me.rdoKeyFile)
Me.grpKey.Location = New System.Drawing.Point(13, 277)
Me.grpKey.Name = "grpKey"
Me.grpKey.Size = New System.Drawing.Size(400, 84)
Me.grpKey.TabIndex = 1
Me.grpKey.TabStop = False
Me.grpKey.Text = "Key"
'
'txtKeyText
'
Me.txtKeyText.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtKeyText.Location = New System.Drawing.Point(93, 49)
Me.txtKeyText.Name = "txtKeyText"
Me.txtKeyText.Size = New System.Drawing.Size(294, 20)
Me.txtKeyText.TabIndex = 4
'
'btnKeyFile
'
Me.btnKeyFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnKeyFile.Location = New System.Drawing.Point(320, 21)
Me.btnKeyFile.Name = "btnKeyFile"
Me.btnKeyFile.Size = New System.Drawing.Size(67, 20)
Me.btnKeyFile.TabIndex = 2
Me.btnKeyFile.Text = "Browse..."
Me.btnKeyFile.UseVisualStyleBackColor = False
'
'rdoKeyFile
'
Me.rdoKeyFile.Location = New System.Drawing.Point(13, 21)
Me.rdoKeyFile.Name = "rdoKeyFile"
Me.rdoKeyFile.Size = New System.Drawing.Size(74, 21)
Me.rdoKeyFile.TabIndex = 0
Me.rdoKeyFile.Text = "Filename"
'
'btnHide
'
Me.btnHide.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnHide.Enabled = False
Me.btnHide.Location = New System.Drawing.Point(233, 257)
Me.btnHide.Name = "btnHide"
Me.btnHide.Size = New System.Drawing.Size(134, 19)
Me.btnHide.TabIndex = 2
Me.btnHide.Text = "Hide Message"
Me.btnHide.UseVisualStyleBackColor = False
'
'btnExtract
'
Me.btnExtract.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnExtract.Enabled = False
Me.btnExtract.Location = New System.Drawing.Point(233, 284)
Me.btnExtract.Name = "btnExtract"
Me.btnExtract.Size = New System.Drawing.Size(134, 20)
Me.btnExtract.TabIndex = 2
Me.btnExtract.Text = "Extract Hidden Text"
Me.btnExtract.UseVisualStyleBackColor = False
'
'tabControl1
'
Me.tabControl1.Controls.Add(Me.tabPage1)
Me.tabControl1.Controls.Add(Me.tabPage2)
Me.tabControl1.Location = New System.Drawing.Point(420, 21)
Me.tabControl1.Name = "tabControl1"
Me.tabControl1.SelectedIndex = 0
Me.tabControl1.Size = New System.Drawing.Size(387, 340)
Me.tabControl1.TabIndex = 2
'
'tabPage1
'
Me.tabPage1.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer))
Me.tabPage1.Controls.Add(Me.grpMessage)
Me.tabPage1.Controls.Add(Me.btnHide)
Me.tabPage1.Controls.Add(Me.btnSaveBitmap)
Me.tabPage1.Controls.Add(Me.chkGrayscale)
Me.tabPage1.Location = New System.Drawing.Point(4, 22)
Me.tabPage1.Name = "tabPage1"
Me.tabPage1.Size = New System.Drawing.Size(379, 314)
Me.tabPage1.TabIndex = 0
Me.tabPage1.Text = "Hide"
'
'grpMessage
'
Me.grpMessage.Controls.Add(Me.rdoMessageText)
Me.grpMessage.Controls.Add(Me.txtMessageFile)
Me.grpMessage.Controls.Add(Me.txtMessageText)
Me.grpMessage.Controls.Add(Me.btnMessage)
Me.grpMessage.Controls.Add(Me.rdoMessageFile)
Me.grpMessage.Location = New System.Drawing.Point(13, 14)
Me.grpMessage.Name = "grpMessage"
Me.grpMessage.Size = New System.Drawing.Size(354, 229)
Me.grpMessage.TabIndex = 0
Me.grpMessage.TabStop = False
Me.grpMessage.Text = "Message"
'
'rdoMessageText
'
Me.rdoMessageText.Checked = True
Me.rdoMessageText.Location = New System.Drawing.Point(13, 42)
Me.rdoMessageText.Name = "rdoMessageText"
Me.rdoMessageText.Size = New System.Drawing.Size(60, 20)
Me.rdoMessageText.TabIndex = 3
Me.rdoMessageText.TabStop = True
Me.rdoMessageText.Text = "Text"
'
'txtMessageFile
'
Me.txtMessageFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtMessageFile.Location = New System.Drawing.Point(87, 21)
Me.txtMessageFile.Name = "txtMessageFile"
Me.txtMessageFile.Size = New System.Drawing.Size(193, 20)
Me.txtMessageFile.TabIndex = 1
'
'txtMessageText
'
Me.txtMessageText.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtMessageText.Location = New System.Drawing.Point(7, 62)
Me.txtMessageText.Multiline = True
Me.txtMessageText.Name = "txtMessageText"
Me.txtMessageText.Size = New System.Drawing.Size(340, 153)
Me.txtMessageText.TabIndex = 4
'
'btnMessage
'
Me.btnMessage.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnMessage.Location = New System.Drawing.Point(280, 21)
Me.btnMessage.Name = "btnMessage"
Me.btnMessage.Size = New System.Drawing.Size(67, 20)
Me.btnMessage.TabIndex = 2
Me.btnMessage.Text = "Browse..."
Me.btnMessage.UseVisualStyleBackColor = False
'
'rdoMessageFile
'
Me.rdoMessageFile.Location = New System.Drawing.Point(13, 21)
Me.rdoMessageFile.Name = "rdoMessageFile"
Me.rdoMessageFile.Size = New System.Drawing.Size(74, 21)
Me.rdoMessageFile.TabIndex = 0
Me.rdoMessageFile.Text = "Filename"
'
'btnSaveBitmap
'
Me.btnSaveBitmap.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnSaveBitmap.Enabled = False
Me.btnSaveBitmap.Location = New System.Drawing.Point(233, 284)
Me.btnSaveBitmap.Name = "btnSaveBitmap"
Me.btnSaveBitmap.Size = New System.Drawing.Size(134, 20)
Me.btnSaveBitmap.TabIndex = 3
Me.btnSaveBitmap.Text = "Save Result"
Me.btnSaveBitmap.UseVisualStyleBackColor = False
'
'chkGrayscale
'
Me.chkGrayscale.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.chkGrayscale.Checked = True
Me.chkGrayscale.CheckState = System.Windows.Forms.CheckState.Checked
Me.chkGrayscale.Location = New System.Drawing.Point(13, 257)
Me.chkGrayscale.Name = "chkGrayscale"
Me.chkGrayscale.Size = New System.Drawing.Size(147, 20)
Me.chkGrayscale.TabIndex = 1
Me.chkGrayscale.Text = "Produce grayscale noise"
'
'tabPage2
'
Me.tabPage2.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(224, Byte), Integer), CType(CType(192, Byte), Integer))
Me.tabPage2.Controls.Add(Me.groupBox3)
Me.tabPage2.Controls.Add(Me.btnExtract)
Me.tabPage2.Location = New System.Drawing.Point(4, 22)
Me.tabPage2.Name = "tabPage2"
Me.tabPage2.Size = New System.Drawing.Size(379, 314)
Me.tabPage2.TabIndex = 1
Me.tabPage2.Text = "Extract"
'
'groupBox3
'
Me.groupBox3.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(224, Byte), Integer), CType(CType(192, Byte), Integer))
Me.groupBox3.Controls.Add(Me.label1)
Me.groupBox3.Controls.Add(Me.txtExtractedMsgFile)
Me.groupBox3.Controls.Add(Me.txtExtractedMsgText)
Me.groupBox3.Controls.Add(Me.btnExtractedMsgFile)
Me.groupBox3.Controls.Add(Me.label3)
Me.groupBox3.Location = New System.Drawing.Point(13, 14)
Me.groupBox3.Name = "groupBox3"
Me.groupBox3.Size = New System.Drawing.Size(354, 256)
Me.groupBox3.TabIndex = 0
Me.groupBox3.TabStop = False
Me.groupBox3.Text = "Nachricht"
'
'label1
'
Me.label1.Location = New System.Drawing.Point(13, 28)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(314, 14)
Me.label1.TabIndex = 10
Me.label1.Text = "Save Extracted Message to File"
'
'txtExtractedMsgFile
'
Me.txtExtractedMsgFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtExtractedMsgFile.Location = New System.Drawing.Point(13, 42)
Me.txtExtractedMsgFile.Name = "txtExtractedMsgFile"
Me.txtExtractedMsgFile.Size = New System.Drawing.Size(260, 20)
Me.txtExtractedMsgFile.TabIndex = 0
'
'txtExtractedMsgText
'
Me.txtExtractedMsgText.BackColor =
System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer),
CType(CType(255, Byte), Integer), CType(CType(192, Byte), Integer))
Me.txtExtractedMsgText.Location = New System.Drawing.Point(13, 97)
Me.txtExtractedMsgText.Multiline = True
Me.txtExtractedMsgText.Name = "txtExtractedMsgText"
Me.txtExtractedMsgText.ReadOnly = True
Me.txtExtractedMsgText.Size = New System.Drawing.Size(327, 153)
Me.txtExtractedMsgText.TabIndex = 5
'
'btnExtractedMsgFile
'
Me.btnExtractedMsgFile.BackColor =
System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer),
CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer))
Me.btnExtractedMsgFile.Location = New System.Drawing.Point(273, 42)
Me.btnExtractedMsgFile.Name = "btnExtractedMsgFile"
Me.btnExtractedMsgFile.Size = New System.Drawing.Size(67, 20)
Me.btnExtractedMsgFile.TabIndex = 1
Me.btnExtractedMsgFile.Text = "Browse..."
Me.btnExtractedMsgFile.UseVisualStyleBackColor = False
'
'label3
'
Me.label3.Location = New System.Drawing.Point(13, 83)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(314, 14)
Me.label3.TabIndex = 10
Me.label3.Text = "Extracted UnicodeText"
'
'picImage
'
Me.picImage.BorderStyle =
System.Windows.Forms.BorderStyle.FixedSingle
Me.picImage.Location = New System.Drawing.Point(13, 55)
Me.picImage.Name = "picImage"
Me.picImage.Size = New System.Drawing.Size(374, 188)
Me.picImage.TabIndex = 0
Me.picImage.TabStop = False
'
'pic_keyvb
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte),
Integer), CType(CType(224, Byte), Integer), CType(CType(192, Byte),
Integer))
Me.ClientSize = New System.Drawing.Size(984, 431)
Me.Controls.Add(Me.tabControl1)
Me.Controls.Add(Me.grpPicture)
Me.Controls.Add(Me.grpKey)
Me.Name = "pic_keyvb"
Me.Text = "picture key stegography"
Me.grpPicture.ResumeLayout(False)
Me.grpPicture.PerformLayout()
Me.grpKey.ResumeLayout(False)
Me.grpKey.PerformLayout()
Me.tabControl1.ResumeLayout(False)
Me.tabPage1.ResumeLayout(False)
Me.grpMessage.ResumeLayout(False)
Me.grpMessage.PerformLayout()
Me.tabPage2.ResumeLayout(False)
Me.groupBox3.ResumeLayout(False)
Me.groupBox3.PerformLayout()
CType(Me.picImage,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
#End Region

''' <summary>
'''
''' </summary>
<STAThread()> _
Private Shared Sub Main()
Application.Run(New pic_keyvb())
End Sub

Private Sub btnHide_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnHide.Click
Dim bitmap As Bitmap = DirectCast(picImage.Image, Bitmap)

'get a stream for the message to hide


Dim messageStream As Stream = GetMessageStream()
If messageStream.Length = 0 Then
MessageBox.Show("Please enter a message or select a file.")
txtMessageText.Focus()
Else
'get a stream fot the key
Dim keyStream As Stream = GetKeyStream()
If keyStream.Length = 0 Then
MessageBox.Show("Please enter a password or select a key
file.")
txtKeyText.Focus()
Else

Try
'hide the message
CryptUtility.HideMessageInBitmap(messageStream, bitmap,
keyStream, chkGrayscale.Checked)
'display result
picImage.Image = bitmap
btnSaveBitmap.Enabled = True
Catch ex As Exception
MessageBox.Show("Exception:" & vbCr & vbLf & ex.Message)
End Try
End If
keyStream.Close()
End If
messageStream.Close()
bitmap = Nothing
End Sub

Private Sub btnExtract_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnExtract.Click
Dim bitmap As Bitmap = DirectCast(picImage.Image, Bitmap)

'empty stream for the extracted message


Dim messageStream As Stream = New MemoryStream()

'get a stream for the key


Dim keyStream As Stream = GetKeyStream()
If keyStream.Length = 0 Then
MessageBox.Show("Please enter a password or select a key file.")
txtKeyText.Focus()
Else

Try
'extract the hidden message from the bitmap
CryptUtility.ExtractMessageFromBitmap(bitmap, keyStream,
messageStream)

'save the message, if a filename is available


If txtExtractedMsgFile.Text.Length > 0 Then
messageStream.Seek(0, SeekOrigin.Begin)
Dim fs As New FileStream(txtExtractedMsgFile.Text,
FileMode.Create)
Dim streamContent As Byte() = New [Byte]
(messageStream.Length - 1) {}
messageStream.Read(streamContent, 0,
streamContent.Length)
fs.Write(streamContent, 0, streamContent.Length)
End If

'display the message - displays chaos, if it's no unicode


text
messageStream.Seek(0, SeekOrigin.Begin)
Dim reader As New StreamReader(messageStream,
UnicodeEncoding.Unicode)
Dim readerContent As [String] = reader.ReadToEnd()
If readerContent.Length > txtExtractedMsgText.MaxLength Then
readerContent = readerContent.Substring(0,
txtExtractedMsgText.MaxLength)
End If
txtExtractedMsgText.Text = readerContent
Catch ex As Exception
MessageBox.Show("Exception:" & vbCr & vbLf & ex.Message)
End Try
End If
'close the streams
messageStream.Close()
keyStream.Close()
bitmap = Nothing
End Sub

''' <summary>Creates a stream to read the message from a string or a


file</summary>
''' <returns>FileStream for a message file, or MemoryStream</returns>
Private Function GetMessageStream() As Stream
Dim messageStream As Stream
If rdoMessageText.Checked Then
Dim messageBytes As Byte() =
UnicodeEncoding.Unicode.GetBytes(txtMessageText.Text)
messageStream = New MemoryStream(messageBytes)
Else
messageStream = New FileStream(txtMessageFile.Text,
FileMode.Open, FileAccess.Read)
End If
Return messageStream
End Function
''' <summary>Creates a stream to read the key from a string or a
file</summary>
''' <returns>FileStream for a key file, or MemoryStream for a
password</returns>
Private Function GetKeyStream() As Stream
Dim keyStream As Stream
If rdoKeyText.Checked Then
Dim keyBytes As Byte() =
UnicodeEncoding.Unicode.GetBytes(txtKeyText.Text)
keyStream = New MemoryStream(keyBytes)
Else
keyStream = New FileStream(txtKeyFile.Text, FileMode.Open,
FileAccess.Read)
End If
Return keyStream
End Function

''' <summary>Opens a bitmap</summary>


''' <param name="fileName">Path and name of the bitmap file</param>
Private Sub SetImage(ByVal fileName As [String])
picImage.Image = New Bitmap(fileName)

btnHide.Enabled = InlineAssignHelper(btnExtract.Enabled, True)


btnSaveBitmap.Enabled = False

Dim index As Integer = fileName.LastIndexOf("\") + 1


If index > 0 Then
fileName = fileName.Substring(index)
End If
grpPicture.Text = "Carrier Bitmap (" & fileName & ")"
End Sub

''' <summary>Displays the OpenFile dialog</summary>


''' <returns>The selected file name, or null</returns>
Private Function GetFileName(ByVal filter As [String]) As [String]
Dim dlg As New OpenFileDialog()
dlg.Multiselect = False
If filter.Length > 0 Then
dlg.Filter = filter
End If

If dlg.ShowDialog(Me) <> DialogResult.Cancel Then


Return dlg.FileName
Else
Return Nothing
End If
End Function

Private Sub rdoMessage_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles rdoMessageFile.Click, rdoMessageText.Click
txtMessageFile.Enabled = rdoMessageFile.Checked
txtMessageText.Enabled = rdoMessageText.Checked
End Sub
Private Sub rdoKey_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rdoKeyFile.Click, rdoKeyText.Click
txtKeyFile.Enabled = rdoKeyFile.Checked
txtKeyText.Enabled = rdoKeyText.Checked
End Sub

Private Sub btnImageFile_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnImageFile.Click
Dim fileName As [String] = GetFileName("Bitmaps (*.bmp)|*.bmp|Tagged
Image File Format(*.tif)|*.tif|PNG-24(*.png)|*.png")
If fileName IsNot Nothing Then
txtImageFile.Text = fileName
SetImage(fileName)
End If
End Sub

Private Sub btnSaveBitmap_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnSaveBitmap.Click
Dim dlg As New SaveFileDialog()
dlg.Filter = "Bitmaps (*.bmp)|*.bmp|Tagged Image File Format(*.tif)|
*.tif|PNG-24(*.png)|*.png"
If dlg.ShowDialog() = DialogResult.OK Then

Dim format As System.Drawing.Imaging.ImageFormat =


System.Drawing.Imaging.ImageFormat.Bmp

If dlg.FilterIndex = 2 Then
format = System.Drawing.Imaging.ImageFormat.Tiff
ElseIf dlg.FilterIndex = 3 Then
format = System.Drawing.Imaging.ImageFormat.Png
End If

'copy the bitmap


Dim img As Image = New Bitmap(picImage.Image)

'close bitmap file


Me.SuspendLayout()
picImage.Image.Dispose()
picImage.Image = Nothing
btnSaveBitmap.Enabled = InlineAssignHelper(btnHide.Enabled,
InlineAssignHelper(btnExtract.Enabled, False))
txtImageFile.Text = [String].Empty
Me.ResumeLayout()

'save new bitmap


img.Save(dlg.FileName, format)
End If
End Sub

Private Sub txtMessageFile_Enter(ByVal sender As Object, ByVal e As


System.EventArgs) Handles txtMessageFile.Enter
rdoKeyFile.Checked = True
End Sub

Private Sub txtMessageText_Enter(ByVal sender As Object, ByVal e As


System.EventArgs) Handles txtMessageText.Enter
rdoKeyText.Checked = True
End Sub

Private Sub txtImageFile_KeyDown(ByVal sender As Object, ByVal e As


System.Windows.Forms.KeyEventArgs) Handles txtImageFile.KeyDown
If e.KeyCode = Keys.Enter Then
SetImage(txtImageFile.Text)
End If
End Sub

Private Sub btnMessage_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnMessage.Click
Dim fileName As [String] = GetFileName([String].Empty)
If fileName IsNot Nothing Then
txtMessageFile.Text = fileName
rdoMessageFile.Checked = True
End If
End Sub

Private Sub btnExtractedMsgFile_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnExtractedMsgFile.Click
Dim dlg As New SaveFileDialog()
If dlg.ShowDialog() = DialogResult.OK Then
txtExtractedMsgFile.Text = dlg.FileName
End If
End Sub

Private Sub btnKeyFile_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnKeyFile.Click
Dim fileName As [String] = GetFileName([String].Empty)
If fileName IsNot Nothing Then
txtKeyFile.Text = fileName
rdoKeyFile.Checked = True
End If
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T,
ByVal value As T) As T
target = value
Return value
End Function
End Class
TESTING
Software Testing Types:

Black box testing - Internal system design is not considered in this type of testing. Tests are
based on requirements and functionality.

White box testing - This testing is based on knowledge of the internal logic of an
application’s code. Also known as Glass box Testing. Internal software and code working
should be known for this type of testing. Tests are based on coverage of code statements,
branches, paths, conditions.

Unit testing - Testing of individual software components or modules. Typically done by the
programmer and not by testers, as it requires detailed knowledge of the internal program
design and code. may require developing test driver modules or test harnesses.

Incremental integration testing - Bottom up approach for testing i.e continuous testing of an
application as new functionality is added; Application functionality and modules should be
independent enough to test separately. done by programmers or by testers.

Integration testing - Testing of integrated modules to verify combined functionality after


integration. Modules are typically code modules, individual applications, client and server
applications on a network, etc. This type of testing is especially relevant to client/server and
distributed systems.

Functional testing - This type of testing ignores the internal parts and focus on the output is
as per requirement or not. Black-box type testing geared to functional requirements of an
application.

System testing - Entire system is tested as per the requirements. Black-box type testing that is
based on overall requirements specifications, covers all combined parts of a system.

End-to-end testing - Similar to system testing, involves testing of a complete application


environment in a situation that mimics real-world use, such as interacting with a database,
using network communications, or interacting with other hardware, applications, or systems if
appropriate.

Sanity testing - Testing to determine if a new software version is performing well enough to
accept it for a major testing effort. If application is crashing for initial use then system is not
stable enough for further testing and build or application is assigned to fix.

Regression testing - Testing the application as a whole for the modification in any module or
functionality. Difficult to cover all the system in regression testing so typically automation
tools are used for these testing types.
Acceptance testing -Normally this type of testing is done to verify if system meets the
customer specified requirements. User or customer do this testing to determine whether to
accept application.

Load testing - Its a performance testing to check system behavior under load. Testing an
application under heavy loads, such as testing of a web site under a range of loads to
determine at what point the system’s response time degrades or fails.

Stress testing - System is stressed beyond its specifications to check how and when it fails.
Performed under heavy load like putting large number beyond storage capacity, complex
database queries, continuous input to system or database load.

Performance testing - Term often used interchangeably with ’stress’ and ‘load’ testing. To
check whether system meets performance requirements. Used different performance and load
tools to do this.

Usability testing - User-friendliness check. Application flow is tested, Can new user
understand the application easily, Proper help documented whenever user stuck at any point.
Basically system navigation is checked in this testing.

Install/uninstall testing - Tested for full, partial, or upgrade install/uninstall processes on


different operating systems under different hardware, software environment.

Recovery testing - Testing how well a system recovers from crashes, hardware failures, or
other catastrophic problems.

Security testing - Can system be penetrated by any hacking way. Testing how well the system
protects against unauthorized internal or external access. Checked if system, database is safe
from external attacks.

Compatibility testing - Testing how well software performs in a particular


hardware/software/operating system/network environment and different combination s of
above.

Comparison testing - Comparison of product strengths and weaknesses with previous


versions or other similar products.

Alpha testing - In house virtual user environment can be created for this type of testing.
Testing is done at the end of development. Still minor design changes may be made as a result
of such testing.

Beta testing - Testing typically done by end-users or others. Final testing before releasing
application for commercial purpose.
IMPLEMENTATION AND MAINTENANCE
Implementation is the process of having systems personnel check out and put new equipment
into use, train users, install the new application and construct any files of data needed to use it.
This phase is less creative than system design. Depending on the size of the organization that
will be involved in using the application and the risk involved in its use, system developers
may choose to test the operation in only one area of the firm with only one or two persons.
Sometimes, they will run both new and old system in parallel way to compare the results. In
still other situations, system developers stop using the old system and start using the new one
the next.

Maintenance is necessary to eliminate errors in the working system during its working life and
to tune the system to any variations in its working environment. Often small system
deficiencies are found as a system is brought into operations and changes are made to remove
them. System planners must always plan for resource availability to carry out these
maintenance functions. The importance of maintenance is to continue to bring the new system
to standards.

Вам также может понравиться