Sunteți pe pagina 1din 48

ABSTRACT

Personal privacy is of utmost importance in the global networked world. One of


the best tools to help people safeguard their personal information is the use of
cryptography. In this research work we present new cryptographic algorithms that
employ the use of asymmetric keys. The proposed algorithms encipher message
into nonlinear equations using public key and decipher by the intended party using
private key. If a third party intercepted the message, it will be difficult to decipher
it due to the multilevel ciphers of the proposed application. This research work
implements a system for the application of Cryptography in Information
Technology. owever, a general overview of cryptography and its various types is
provided and various algorithms are discussed. ! detailed review of the sub"ect of
network security, hash key algorithm and cryptography in digital signatures is then
presented. The purpose of the research work is to develop a system that one can
used to demonstrate the application of cryptography in Information Technology.
The #oftware methodology used is the $aterfall methodology.
CHAPTER ONE
INTRODUCTION
1.1BACKROUND OF STUDY
%ata #ecurity is one of the ma"or concerns of every organi&ation today,
information are store in different location, un'authori&ed access to such
information can reduce the integrity of such information and also users can
easily temper with such data in order to avoid a situation where system
administrator and un'authori&ed users who gain access to such information, is
good to make the information un'meanifull so that he(she will not temper with
the integrity of such information. !lso Information that are communicate over
the web are not secured if such information are not properly secured since
computer hackers can access such information before it get to the recipient and
thereby the integrity of such information is violated, in order to secured our
information the need to employed the use of cryptography and ash key
algorithm becomes a sub"ect of focus in this research work, Cryptography is the
science of using mathematics to encrypt and decrypt data. Cryptography
enables you to store sensitive information or transmit it across insecure
networks )like the Internet* so that it cannot be read by anyone e+cept the
intended recipient. $hile cryptography is the science of securing data,
Cryptanalysis is the science of analy&ing and breaking secure communication.
Classical cryptanalysis involves an interesting combination of analytical
reasoning, application of mathematical tools, pattern finding, patience,
determination, and luck. Cryptanalysts are also called attackers. Cryptology
embraces both cryptography and cryptanalysis. ! related discipline is
Stegangrap!y, which is the science of hiding messages rather than making them
unreadable. #teganography is not cryptography, it is a form of coding. It relies
on the secrecy of the mechanism used to hide the message. If, for e+ample, you
encode a secret message by putting each letter as the first letter of the first word
of every sentence, it-s secret until someone knows to look for it, and then it
provides no security at all. .There are two kinds of cryptography in this world/
cryptography that will stop your kid sister from reading your files, and
cryptography that will stop ma"or governments from reading your files )#trong
and $eak cryptography*.
Cryptography can be strong or weak, as e+plained above. Cryptographic
strength is measured in the time and resources it would require to recover the
plainte+t. The result of strong cryptography is cipher te+t that is very difficult
to decipher without possession of the appropriate decoding tool. ow
difficult0 1iven all of today-s computing power and available time2even a
billion computers doing a billion checks a second2it is not possible to
decipher the result of strong cryptography before the end of the universe.
One would think, then, that strong cryptography would hold up rather well
against even an e+tremely determined cryptanalyst. $ho-s really to say0 3o
one has proven that the strongest encryption obtainable today will hold up
under tomorrow-s computing power. owever, the strong cryptography
employed by P1P is the best available today. 4igilance and conservatism will
protect you better, however, than claims of impenetrability.
! cryptographic algorithm, or cipher, is a mathematical function used in the
encryption and decryption process. ! cryptographic algorithm works in
combination with a key2a word, number, or phrase2to encrypt the plainte+t.
The same plainte+t encrypts to different cipher te+t with different keys. The
security of encrypted data is entirely dependent on two things/ the strength of
the cryptographic algorithm and the secrecy of the key. ! cryptographic
algorithm, plus all possible keys and all the protocols that make it work,
comprise a cryptosystem.
1." STATE#ENT OF PROB$E#S
5asically in most organi&ation today data security is at a very low level where
information of the organi&ation are kept in form of files in the cabinet,
information of such lack security since un'authori&ed users can easily gain
access to such information and the integrity of such information is lost, even in
some organi&ation that have automated system the system lacks security since
even the system administrator can easily temper with the information. It is
necessary to secure information. 6ven in our email system today there are
attacks against password where one can guess user password, also spyware are
developed that steals user password and store it in the system where the original
owner can access those password thereby the integrity of such email is violated.
7any systems break because they rely on user'generated passwords. 8eft to
themselves, people don9t choose strong passwords. If they9re forced to use strong
passwords, they can9t remember them. If the password becomes a key, it9s usually
much easier''and faster''to guess the password than it is to brute'force the key,
we9ve seen elaborate security systems fail in this way. #ome user interfaces make
the problem even worse/ limiting the passwords to eight characters, converting
everything to lower case, etc. 6ven passphrases can be weak/ searching through
:;'character phrases is often much easier than searching through <:'bit random
keys. $e9ve also seen key'recovery systems that circumvent strong session keys by
using weak passwords for key'recovery.
1.% AI#S AND OB&ECTI'ES
This research work is aims at discussing the application of cryptography in
Information Technology.
The Ob"ectives of the research work is to develop a system that will secure data
using cryptography and encryption algorithm so that the system will attains the
following goals.
Cn(i)entiality/ Information can only be seen by authori&ed entities
Integrity/ 6nsuring that information is not corrupted or alters by un'authori&ed
entities.
A*aila+ility, 1uaranteeing that the information is available to authori&ed
entities and !uthentication providing assurance of the identities of entities.
1.- SI.NIFICANCE OF THE STUDY
#ecuring data is one of the ma"or things every organi&ation will want to do
since the information is very important for their day to day running of the
organi&ation. 6ncryption is one of the most important and most affordable
defenses available to a small business. If a hacker manages to get past all your
other security measures, good encryption properly used will stop him in his
tracks.The way most organi&ation information are temper with since there is no
standard security measure for securing such information, for an organi&ation
that have an automated system the database is not encrypted so any users that
have access to the database can easily temper with such information in order to
prevent such incident from happening the need to secure such data using
cryptography and hash key algorithm becomes a sub"ect of interest in these
research work, the use of cryptography and modern encryption techniques are
used to secure data.
1./ SCOPE OF THE STUDY
Cryptography in Information Technology for #ecuring data communication is a
$indows based model of software system for cryptographic protection of data in
distribution information systems. It uses symmetrical and asymmetrical algorithms
and provides the following services. The scope of the research work covers the
following as stated below.
identification and authentication of users,
identification and authentication of applications,
cryptographic protection on file and block data levels,
digital signature,
access control to cryptographic functions,
logs,
Cryptographic application program interface )C!PI*.
1.0 $I#ITATION OF THE STUDY
The system is limited to securing data using the e+isting modern encryption
algorithms such as !6# )!dvanced encryption standard*,%6#)%igital
encryption standard*,ash key algorithms e.t.c
1.1 RESEARCH #ETHODO$O.Y
To achieve this research work, we employed the underlying technique to gather
data and analy&ed the data to accomplish the task. The #oftware methodology used
is the waterfall method. The waterfall model is a sequential design process, often
used in software development processes, in which progress is seen as flowing
steadily downwards )like a waterfall* through the phases of Conception, Initiation,
!nalysis, %esign, Construction, Testing, Production(Implementation and
7aintenance. The unmodified =waterfall model=. Progress flows from the top to
the bottom, like a waterfall. The waterfall development model originates in the
manufacturing and construction industries/ highly structured physical
environments in which after'the'fact changes are prohibitively costly, if not
impossible. #ince no formal software development methodologies e+isted at the
time, this hardware'oriented model was simply adapted for software development.
1.2 DEFINITION OF TER#S
ENCRYPTION is the process of transforming information )referred to as
plainte+t* using an algorithm )called a cipher* to make it unreadable to anyone
e+cept those possessing special knowledge, usually referred to as a key
DECRYPTION/ The reverse process, i.e., to make the encrypted information
readable again i.e., to make it unencrypted*
CRYPTO.RAPHY, Is the science of using mathematics to encrypt and
decrypt data.
CRYPTANA$YSIS, Is the science of analy&ing and breaking secure
communication.
STE.ANO.RAPHY, This is the science of hiding messages rather than making
them unreadable.
CHAPTER T3O
$ITERATURE RE'IE3
".1 Re*ie4 ( Relate) 3r5
)5ellare, et al. >;;;*#6C?@ITAB in this contemporary scenarios has become a
more sensible issue either it may be in .@6!8 $O@8%B or in the .CA56@
$O@8%B .in this world as opposed to the cyber world an attack is often preceded
by information gathering. 3etwork security is a complicated sub"ect, historically
only tackled by well'trained and e+perienced e+perts. owever, as more and more
people becomeB wired99, an increasing number of people need to understand the
basics of security in a networked world. Our paper covers different kinds of threats
C firewalls in the network by implementation of different security services using
various security mechanisms. The security mechanisms are primarily based on
cryptographic algorithms like symmetric'%6#, !6#, asymmetric'@#!, 6CC.
1enerally, the logical conclusion is to use both kind of algorithms and their
combinations to achieve optimal speed and security levels. It is hoped that the
reader will have a wider perspective on security in general, and better understand
how to reduce and manage risk personally.
"." CRYPTO.RAPHY
)Dimmermann, >;;E* One way to strengthen security in computer systems is to
encrypt sensitive records and messages in transit and in storage. The basic model
of a cryptographic system is illustrated in Figure below. The original unenciphered
te+t is called the plainte+t. The act of converting a plain te+t message to its
cipherte+t form is called enciphering )Potdar, >;;:*. In its cipher form, a message
cannot be read by anyone but the intended receiver. @eversing that act )i.e., cipher
te+t form to plain te+t message* is deciphering. 6nciphering and deciphering are
more commonly referred to as encryption and decryption, respectively.
Fig ".6 Data En7ryptin an) De7ryptin Pr7ess
#ODERN KEY8BASED CRYPTO.RAPHIC TECHNI9UES
There are several modern key'based cryptographic techniques. The two common
key based encryption techniques are symmetric and asymmetric key cryptography
)%iaa, >;G;*.In symmetric key cryptography, the same key is used for both
encryption and decryption. In asymmetric schemes, one key is used for encryption
and another is used for decryption )@itter, >;;H* the increased confidence in the
integrity of systems that use encryption is based on the notion that cipherte+t
should be very difficult to decipher without knowledge of the key )7ilenkovic,
GEE>*
TYPES OF ATTACKS
There are several types of code'breaking attacks. The first, known as the cipherte+t
attack, occurs when an adversary comes into possession of only the cipherte+t
)7ilenkovic, GEE>* The known plainte+t problem occurs when the intruder has
some matched portions of the cipherte+t and the plainte+t )!lallayah,>;G;* The
most dangerous is the chosen plainte+t problem, in which the attacker has the
ability to encrypt pieces of plainte+t at will. 5rute'force is the ultimate attack on a
cipher, by which all possible keys are successively tested until the correct one is
encountered )!lallayah,>;G;* ,Codebook attacks are attacks that take advantage of
the property by which a given block of plainte+t is always encrypted to the same
block of cipherte+t as long as the same key is used. ! =man'in'the'middle= attack
is an attack that is placed by an active attacker who can listen to the
communication between two entities and can also change the contents of this
communication. $hile performing this attack, the attacker pretends to be one of
the parties in front of the other party.
"." ANA$YSIS OF THE E:ISTIN. SYSTE#
Over the year data security has pose a lot problem as the result of unauthori&ed
access to relevant data. From the investigation gather from the e+isting system, it
was spell out that the method employed in data security where "ust mere password
of relevant document in directory. Password protection where the only measure
used to secure data from unauthori&ed user of the system, which can be overwrite
by hackers thereby e+posing data to unauthori&ed user.
".% AD'ANTA.ES OF THE E:ISTIN. SYSTE#
The e+isting system is easy to implement since the password does not
involved key or mathematical algorithm
%ata secured by mere password.
".- DISAD'ANTA.ES OF THE E:ISTIN. SYSTE#
#ince the e+isting system used only password protection the confidentiality
of the data is violated.
The e+isting may e+pose the content of the document to hackers because of
weak password employed by the user of the system.
There is no integrity of data
!uthentication and the accuracy of data is not guarantee
"./ THE PROPOSE SYSTE#
The design for the combining two different techniques is purely based on the idea
distort the message and hide the e+istence of the distorted message and for getting
back the original message retrieve the distorted message and regain the actual
message by reversal of the distortion process. ere we design the system with
three modules
For Cryptography C ash key algorithm ' Crypto 7odule
For #teganography ' #tego 7odule
For e+tra security ' #ecurity 7odule
The e+tra security module that we are providing make this system highly secured.
The process flow for the system is as follows/
Crypt #);le,
For Crypto 7odule the following steps are considered for encrypting the data
)@efer Fig;re".1<,
Insert te+t for encryption.
!pply !6# algorithm using G>I bit key )Jey G*.
1enerate Cipher Te+t in he+adecimal form.
Fig ".1 Crypt #);le
Se7;rity #);le,
This is an intermediate module which provides an e+tra security features to
our newly developed system. This module is used to modify the cipher te+t
and to generate two e+tra keys. In the reverse process it regenerates the
original cipher te+t )@efer Fig;re"."< .5efore the hiding process this module
works as follows/
#eparate the alphabets and digits from the cipher te+t.
Jeep track of the original position of the alphabet and the digits in the form
of a secret key )Jey K*.
#eparate first seven alphabets retrieved from first step and add the remaining
alphabets at the end of the separated digits as in the first step. This generates
the second key )Jey :*.
Fig "." Se7;rity #);le
Crypt #);le=Re*erse Pr7ess<,
For Crypto 7odule the following steps are considered for retrieving the
original te+t. For more details refer Fig;re ".%,
1et the above retrieved cipher te+t.
@everse !6# algorithm by using Jey G.
1et the original message
Fig ".% Steg #);le
".1 AD'ANTA.ES OF PROPOSED SYSTE#
The proposed solution is highly secure since' It-s a combination of two highly
secured techniques
a* !6# for cryptography
b* %CT manipulation for #teganography.
c* 4ery secure
d* Fle+ibility
e* #implicity
N;>+er ( Keys, This system contains total : keys.
a* One G>I bits private key for !6# algorithm
b* One L< bits private key for scrambling the cipher te+t.
c* Two e+tra private generated keys for retrieving the original message.
".2 DISAD'ANTA.E OF PROPOSED SYSTE#
igh Cost of Implementation
#ecurity can be breach since there is only two keys are require i.e public and
private key.
".? &USTIFICATION OF THE PROPOSED SYSTE#
5ased on the various benefits of the proposed system the system "ustification
encompass the cost of implementation even though the cost is high it will really
improve the process of developing a system that will reduce the rate at which
information are hacked and ensure the security of information that are sent.
CHAPTER THREE
SYSTE# DESI.N
%.1 Syste> Design
#ystems design is the process of defining the architecture, components, modules,
interfaces, and data for a system to satisfy specified requirements. One could see it
as the application of systems theory to product development. There is some overlap
with the disciplines of systems analysis, systems architecture and systems
engineering. If the broader topic of product development =blends the perspective of
marketing, design, and manufacturing into a single approach to product
development,= then design is the act of taking the marketing information and
creating the design of the product to be manufactured. #ystems design is therefore
the process of defining and developing systems to satisfy specified requirements of
the user. ?ntil the GEE;s systems design had a crucial and respected role in the data
processing industry. In the GEE;s standardi&ation of hardware and software resulted
in the ability to build modular systems. The increasing importance of software
running on generic platforms has enhanced the discipline of software engineering.
Ob"ect'oriented analysis and design methods are becoming the most widely used
methods for computer systems design. The ?78 has become the standard
language in ob"ect'oriented analysis and design. It is widely used for modeling
software systems and is increasingly used for high designing non'software systems
and organi&ations.
%."O+@e7ti*es ( Design
The purpose of systems analysis and design is for a business to increase their
efficiency, because when you look at a current system you will see flaws that need
fi+ed and within the new system that you design you will take these into
consideration. ! new system will make the business more profitable. The
ob"ectives of this pro"ect are to be able to demonstrate the processes involve in the
application of cryptography in Information Technology for securing data
communication.
%.% #ain #en;
7ain 7enu/ $hich consist of a @ibbon with various tab
?sers !uthentication/ This handles the authentication of various users
that access the system
File 6ncryption/ This modules handle file encryption and decryption
Fig %.1 Cryptgrap!i7 #ain #en;
Cryptography Main Menu
Data Encryption for
System Setup
Decryption of Users
That Log Into the
System
Encrypt &
Decrypted Users
Activities and Fies
in the System
%.-Inp;tA;tp;t Design
The input(output design specifies how data are entered and accepted by the system
for processing. The design specifies how the user interacts with the system to direct
the action to be taken. The types of input controls used are Te+tbo+es, Combo 5o+,
8ist 4iews and 7enus
Fig %." %ata 6ncryption ?sing Cryptography and ash Jey !lgorithm
Techniques for both Te+t and Files of any Jind.
K.L O*erall Data Fl4 Diagra>
Fig 3.3 Flow Diagram for the System
%.0 Algrit!>s
P;+li7 5ey 7ryptgrap!y
Public'key algorithms are asymmetric algorithms and, therefore, are based on the
use of two different keys, instead of "ust one. In public'key cryptography, the two
keys are called the private key and the public key
Pri*ate 5ey/ This key must be known only by its owner.
P;+li7 5ey/ This key is known to everyone )it is public*
Relatin +et4een +t! 5eys/ $hat one key encrypts, the other one
decrypts, and vice versa. That means that if you encrypt something with my
public key )which you would know, because it9s public /'*, I would need my
private key to decrypt the message.
%.0.1 A se7;re 7n*ersatin ;sing p;+li785ey 7ryptgrap!y
In a basic secure conversation using public'key cryptography, the sender encrypts
the message using the receiver9s public key. @emember that this key is known to
everyone. The encrypted message is sent to the receiving end, who will decrypt the
message with his private key. Only the receiver can decrypt the message because
no one else has the private key. !lso, notice how the encryption algorithm is the
same at both ends/ what is encrypted with one key is decrypted with the other key
using the same algorithm.
Fig %.- 6ncryption !lgorithm Flow %iagram
%.0." Prs an) 7ns ( p;+li785ey syste>s
Public'key systems have a clear advantage over symmetric algorithms/ there is no
need to agree on a common key for both the sender and the receiver. !s seen in the
previous e+ample, if someone wants to receive an encrypted message, the sender
only needs to know the receiver9s public key )which the receiver will provide,
publishing the public key in no way compromises the secure transmission*. !s long
as the receiver keeps the private key secret, no one but the receiver will be able to
decrypt the messages encrypted with the corresponding public key. This is due to
the fact that, in public'key systems, it is relatively easy to compute the public key
from the private key, but very hard to compute the private key from the public key
)which is the one everyone knows*. In fact, some algorithms need several months
)and even years* of constant computation to obtain the private key from the public
key.
Fig %./ Jey 1enerator
%.1 USE CASE DIA.RA# FOR THE ENTIRE SYSTE#
SENDER
INTRUDER
RECIE'ER
Send Data to Users via
Emai or Fie Transfer Using
FT! Appication
Data Encryption of Te"t and
Fies #ith Secret $ey
Intruders that May Intercept
data Transfer
%o Access to a Third party
$ey& Access denied 'ecause
of strong cryptography
(eceive Message or )es
Decrypt Fies receive #ith
a !rivate $ey
%.2 C!i7e ( Prgra>>ing $ang;age
7icrosoft 4isual 5asic.3et >;G; was used as the Front 6nd )?ser Interface
and my Programming 8anguage* tool because of its fle+ibility, bend ability
and very easy deploying application.
CHAPTER FOUR
SYSTE# I#P$E#ENTATION AND DOCU#ENTATION
-.1INTRODUCTION
This is the coordination and controlling of the activities needed to put the
system in operation. The goal is to bring the proposed system to life. This
stage mainly involves installation of the hardware to support the system such
as the $eb #erver
The implementation of this system entails all those processes undertaken
from the conversion of the old system to the new system, final documents
compilation and users training. The overall system is user friendly, i.e. it was
designed so that any level of user can easily use it without having any
problem.
-."SYSTE# RE9UIRE#ENT
For the effective running of the new system, the following are required a
client Operating #ystem/ ! server operating system such as $indows 4ista.
$indow H and above will host the application server that will contain the
files
7icrosoft %ot 3et Framework ).36T* :.;/ %ependencies used by the
!pplication resides here such as %ynamic 8inked 8ibraries )%88* files.
-.%PROCEDURE FOR SOFT3ARE INSTA$$ATION
#teps to install the new system on a workstation
G. Check if .36T :.; is installed by checking if this folder e+ists
=C/M$indowsM7icrosoft.36TMFrameworkMv:.;.K;KGE= )if not install
it*.
>. %ouble Click on the setup.e+e
K. Follow the $i&ard %ialog bo+ Instruction and click 3e+t.
:. Click on Finish, when the software is completed.
L. Open the !ll Program and click on Crypto.
-.-TESTIN.
This is ensuring that the program runs as e+pected. Free of errors. The
system developed was not free of bugs. $e therefore employed the
following testing and debugging method to checks for errors.
%esk Checking
?nit Testing
Integration Testing
!lpha Testing
5eta Testing
-.-.1 DESK CHECKIN.
This means reading through or checking the programs to make sure that it is
free from errors and that the logic works well )correctly* before it is entered
into the computer.
-.-." UNIT TESTIN.
ere the different modules are tested and the specifications produced
during design for the modules. ?nit Testing is essential for verification of
the goal and to test the internal logic of the modules. ?nit testing was
conducted to the different modules of the pro"ect. 6rrors were noted
down and corrected down immediately and the program clarity as
increased.
-.-.% INTE.RATION TESTIN.
It is a systematic testing of constructing structure. !t the same time tests are
conducted to uncover errors associated with the interface. It need not be the
case, that software whose modules when run individually and showing
perfect results will also perfect results when run as a whole.
-.-.- A$PHA TESTIN.
#ome errors were not detected during desk checking, so we prepared some
test data with known output to test the program output if it tallies with the
e+pected result.
-.-./ BETA TESTIN.
This testing is done with real life data and real users. !t this stage, we tested
all possibilities that may lead to failure of the program. !fter testing of the
program and we are now sure that it is free from errors we proceeded to the
ne+t phase #ystem Implementation.
-./SYSTE# CON'ERSION
This is the process of changing over from the old system of banking to the
new one secure method. There e+ist various conversion strategies, they
include
Pilot Conversion
Phased Conversion
Parallel Conversion
-./.1 PI$OT CON'ERSION
In the system conversion strategy, the system is deployed at a station and
tested there while other stations use the e+isting system. If the new system
fails at one station, the others will not be affected and switching back would
be very easy.
-./." PHASED CON'ERSION
This strategy involves implementing the new system in a phased way, so that
different parts of the organi&ation are implemented in different subsequent
time slots
-./.% PARA$$E$ CON'ERSION
In this strategy, to reduce risk, the old and new system run simultaneously
for some period of time after which, if the criteria for the new system are
met, the old system is disabled. The process requires careful planning and
control and a significant investment in labour hours.
-.0TRAININ. OF THE OPERATORS
The users of the system would be trained on how to operate the new system.
This will enable them to benefits from the usage of the new system.
-.1SYSTE# DOCU#ENTATION
This is defined as writing down the properties of the new system for
reference purpose. The design will be put in a file called #ystem
#pecification and it contains
%ata Input methods/ talking about the data required, data capture method,
data checking and control procedures.
%ata Output methods/ Information produced form the system whether
regular, e+ception or other reports.
-.2#AINTENANCE DETAI$S
6very system out of usage will become out of sync with current trends and
cutting edge technologies. #ystem maintenance has to do with ad"usting and
improving the system performance, reliability, efficiency and effectiveness
through system audits, user feedback and periodic evaluation. It involves
updating and upgrading the system to keep pace with new products,
services, customer demand, and government regulations.
CHAPTER FI'E
SU##ARY AND CONC$USION
/.1 SU##ARY
#torage systems are increasingly sub"ect to attacks. Cryptographic file systems
mitigate the danger of e+posing data by using encryption and integrity protection
methods and guarantee end'to'end security for their clients. This paper describes a
generic design for cryptographic file systems and its reali&ation in a distributed
storage'area network )#!3* file system. Jey management is integrated with the
meta'data service of the #!3 file system. The implementation supports file
encryption and integrity protection through hash trees. 5oth techniques have been
implemented in the client file system driver. $e also demonstrate that the overhead
is noticeable for some artificially constructed use cases, but that it is very small for
typical file system applications.
/." CONC$USION
The work accomplished during this pro"ect can be summari&ed with the following
points/ In this pro"ect we have presented a new system for the combination of
different cryptography algorithms using four keys which could be proven a highly
secured method for data communication in near future. #teganography, especially
combined with cryptography, is a powerful tool which enables people to
communicate without possible eavesdroppers even knowing there is a form of
communication in the first place. The main advantage of this #ystem is that the
method used for encryption, !6#, is very secure and the %CT transformation
#teganography techniques are very hard to detect.
/.% RECO##ENDATION
The system is highly recommended to all organi&ation and individual for
protecting their files and documents by encrypting the content of their work such
that the only intend reader or user will be able to decrypt the files and documents.
The system can also be improve for future purpose by tracing packet sent over a
network in order not for an intruder to hack the content of their file and decrypted
the files and document before getting to the intended user.
@6F6@63C6#
!lallayah, J.7., !bd 6l'$ahed $.F.7. and !lhamani !.)>;G;* !ttack Of
!gainst #implified %ata 6ncryption #tandard Cipher #ystem ?sing 3eural
3etworksB. Journal of Computer Science, , <)G*, pp. >E'KL.
%iaa, #.!.7, atem, 7.!.J and 7ohiy 7.. )>;G;*. .6valuating The
Performance of #ymmetric 6ncryption !lgorithmsB International Journal of
Network Security, >;G;, G;)K*, pp.>GK'>GE
Figg. 5. )>;;:*. Cryptography and 3etwork #ecurity. Internet/
http/(www.homepages.dsu.edu(figgw(CryptographyN>;CN>;3etworkN>
;#ecurity.ppt. O7arch G<, >;G;P.
Qakobsen T. and Jnudsen 8.@.. )>;;G*. !ttack on 5lock of Ciphers of 8ow
!lgebraic %egree. Journal of Cryptography, 3ew Aork, 1)K*, pp.GEH'>G;.
7ilenkovic 7.) GEE>.* !perating System" Concepts and #esign, 3ew Aork/
7c1rew'ill, Inc.,
7oore 1.$.. )>;;G*. Cryptography 7ini'Tutorial. 8ecture notes ?niversity of
7aryland #chool of 7edicine. Internet/ http/((www.medparse.com(whatcryp.htm
O7arch G<, >;;EP.
@udolf %..)>;;E* .%evelopment and !nalysis of 5lock Cipher and %6# #ystemB.
Internet/ http/((www.cs.usask..ca(Rdtr:<H(:;;(, >;;;,
$ang .. )>;;>*. #ecurity !rchitecture for The Teamdee #ystem. !n unpublished
7#c Thesis submitted to Polytechnic Institution and #tate ?niversity, 4irginia,
?#!.
Dimmermann P.@..) >;;E* !n Introduction to Cryptography. 1ermany/ 7IT press.
!vailable/ http/((www.pgpi.org(doc(pgpintro, GEEL,
APPENDI: A
SOURCE CODES
Imports System*Security*Cryptography
Imports System*Te"t
!u'ic Cass Crypto
Impements IDisposa'e
+(egion ,-o'a varia'es and initiai.ation,
/Add your go'a varia'es here*
/Customi.e Su' %e# for your re0uirements*
!u'ic Su' %e#12
My3ase*%e#12
End Su'
+End (egion
+(egion ,IDisposa'e impementation and reated code,
/%ormay this su' can 'e eft as is*
!u'ic 4veroads Su' Dispose12 Impements IDisposa'e*Dispose
Dispose1True2
-C*SuppressFinai.e1Me2
End Su'
!rotected 4verrida'e 4veroads Su' Dispose13y5a disposing As 3ooean2
If disposing Then
/Free managed o'6ects*
End If
/Free unmanaged o'6ects*
/Set arge )eds to nu*
End Su'
/%ormay this su' can 'e eft as is*
!rotected 4verrides Su' Finai.e12
Dispose1Fase2
End Su'
+End (egion
+(egion ,Cass speci)c code,
!u'ic Event Crypto!rogress13y5a sender As 4'6ect& 3y5a e As CryptoEventArgs2
!u'ic Event CryptoCompeted13y5a sender As 4'6ect& 3y5a e As CryptoEventArgs2
!u'ic Function 7ashStringTo3ase89String13y5a vaue As String2 As String
(eturn Me*7ashStringTo3ase89String1vaue& %othing2
End Function
!u'ic Function 7ashStringTo3ase89String13y5a vaue As String& 3y5a provider As
7ashAgorithm2 As String
If vaue Is %othing 4rEse vaue : ,, Then
Thro# %e# Argument%uE"ception1,vaue,& ,/vaue/ shoud not 'e %othing
1nu in C+2 or String*Empty*,2
End If
Dim 'ytes12 As 3yte
If provider Is %othing Then provider : %e# S7A;<=Managed
'ytes : ASCIIEncoding*ASCII*-et3ytes1vaue2
'ytes : provider*Compute7ash1'ytes2
provider*Cear12
(eturn Convert*To3ase89String1'ytes2
End Function
!u'ic Function 7ashStringTo3yteArray13y5a vaue As String2 As 3yte12
(eturn Me*7ashStringTo3yteArray1vaue& %othing2
End Function
!u'ic Function 7ashStringTo3yteArray13y5a vaue As String& 3y5a provider As
7ashAgorithm2 As 3yte12
If vaue Is %othing 4rEse vaue : ,, Then
Thro# %e# Argument%uE"ception1,vaue,& ,/vaue/ shoud not 'e %othing
1nu in C+2 or String*Empty*,2
End If
Dim 'ytes12 As 3yte
If provider Is %othing Then provider : %e# S7A;<=Managed
'ytes : ASCIIEncoding*ASCII*-et3ytes1vaue2
'ytes : provider*Compute7ash1'ytes2
provider*Cear12
(eturn 'ytes
End Function
!u'ic Function EncryptStringTo3ase89String13y5a vaue As String& 3y5a pass#ord As
String2 As String
(eturn Me*EncryptStringTo3ase89String1vaue& pass#ord& %othing2
End Function
!u'ic Function EncryptStringTo3ase89String13y5a vaue As String& 3y5a pass#ord As
String& 3y5a provider As SymmetricAgorithm2 As String
Dim pass#ord3ytes12 As 3yte
Dim >ey12 As 3yte
Dim memoryStream As I4*MemoryStream
Dim cryptoStream As CryptoStream
Dim header As String
Dim output As String
If vaue Is %othing 4rEse vaue : ,, Then
Thro# %e# Argument%uE"ception1,vaue,& ,/vaue/ shoud not 'e %othing
1nu in C+2 or String*Empty*,2
End If
If pass#ord Is %othing 4rEse pass#ord : ,, Then
Thro# %e# Argument%uE"ception1,pass#ord,& ,/pass#ord/ shoud not 'e
%othing 1nu in C+2 or String*Empty*,2
End If
If provider Is %othing Then provider : %e# (i6ndaeManaged
(eDim >ey1provider*Lega$eySi.es1?2*Ma"Si.e @ A B <2
provider*3oc>Si.e : provider*Lega3oc>Si.es1?2*Ma"Si.e
pass#ord3ytes : Me*7ashStringTo3yteArray1pass#ord2
Array*Copy1pass#ord3ytes& >ey& >ey*Length2
provider*$ey : >ey
provider*-enerateI512
header : Me*7ashStringTo3ase89String1Convert*To3ase89String1pass#ord3ytes2
& Convert*To3ase89String1provider*I522*!ad(ight1<=C2 &
Convert*To3ase89String1provider*I52*!ad(ight1<=C2
If Type4f provider Is DESCryptoService!rovider Then
header &: ,?<,
EseIf Type4f provider Is (C=CryptoService!rovider Then
header &: ,?=,
EseIf Type4f provider Is TripeDESCryptoService!rovider Then
header &: ,?D,
EseIf Type4f provider Is (i6ndaeManaged Then
header &: ,?9,
End If
memoryStream : %e# I4*MemoryStream
memoryStream*SetLength1?2
cryptoStream : %e# CryptoStream1memoryStream& provider*CreateEncryptor12&
CryptoStreamMode*Erite2
cryptoStream*Erite1Encoding*ASCII*-et3ytes1vaue2& ?&
Encoding*ASCII*-et3ytes1vaue2*Length2
cryptoStream*FushFina3oc>12
output : header & Convert*To3ase89String1memoryStream*ToArray2
memoryStream*Cose12
cryptoStream*Cear12
provider*Cear12
(eturn output
End Function
!u'ic Function DecryptStringFrom3ase89String13y5a vaue As String& 3y5a pass#ord As
String2 As String
Dim provider As SymmetricAgorithm
Dim pass#ord3ytes12 As 3yte
Dim >ey12 As 3yte
Dim memoryStream As I4*MemoryStream
Dim cryptoStream As CryptoStream
Dim output As String
If vaue Is %othing 4rEse vaue : ,, Then
Thro# %e# Argument%uE"ception1,vaue,& ,/vaue/ shoud not 'e %othing 1nu in 532 or
String*Empty*,2
End If
If pass#ord Is %othing 4rEse pass#ord : ,, Then
Thro# %e# Argument%uE"ception1,pass#ord,& ,/pass#ord/ shoud not 'e %othing 1nu in
532 or String*Empty*,2
End If
Seect Case vaue*Su'string1=;9& =2
Case ,?<,
provider : %e# DESCryptoService!rovider
Case ,?=,
provider : %e# (C=CryptoService!rovider
Case ,?D,
provider : %e# TripeDESCryptoService!rovider
Case ,?9,
provider : %e# (i6ndaeManaged
End Seect
(eDim >ey1provider*Lega$eySi.es1?2*Ma"Si.e @ A B <2
provider*3oc>Si.e : provider*Lega3oc>Si.es1?2*Ma"Si.e
pass#ord3ytes : Me*7ashStringTo3yteArray1pass#ord2
Array*Copy1pass#ord3ytes& >ey& >ey*Length2
provider*$ey : >ey
provider*I5 : Convert*From3ase89String1vaue*Su'string1<=C& <=C2*Trim2
If %ot vaue*Su'string1?& <=C2*Trim :
Me*7ashStringTo3ase89String1Convert*To3ase89String1pass#ord3ytes2 &
Convert*To3ase89String1provider*I522 Then
/If the pass#ord is incorrect& do some cean up 'efore thro#ing an
e"ception*
provider*Cear12
Thro# %e# ArgumentE"ception1,The pass#ord speci)ed is invaid*,2
End If
memoryStream : %e# I4*MemoryStream
memoryStream*SetLength1?2
cryptoStream : %e# CryptoStream1memoryStream& provider*CreateDecryptor12&
CryptoStreamMode*Erite2
cryptoStream*Erite1Convert*From3ase89String1vaue*Su'string1=;822& ?&
Convert*From3ase89String1vaue*Su'string1=;822*Length2
cryptoStream*FushFina3oc>12
output : ASCIIEncoding*ASCII*-etString1memoryStream*ToArray2
memoryStream*Cose12
cryptoStream*Cear12
provider*Cear12
(eturn output
End Function
!u'ic Su' EncryptFie13y5a inFie As String& 3y5a outFie As String& 3y5a pass#ord As
String2
Me*EncryptFie1inFie& outFie& pass#ord& %othing& ?2
End Su'
!u'ic Su' EncryptFie13y5a inFie As String& 3y5a outFie As String& 3y5a pass#ord As
String& 3y5a provider As SymmetricAgorithm2
Me*EncryptFie1inFie& outFie& pass#ord& provider& ?2
End Su'
!u'ic Su' EncryptFie13y5a inFie As String& 3y5a outFie As String& 3y5a pass#ord As
String& 3y5a provider As SymmetricAgorithm& 3y5a 'uFerSi.e As Integer2
Dim pass#ord3ytes12 As 3yte
Dim >ey12 As 3yte
Dim inStream As I4*FieStream
Dim outStream As I4*FieStream
Dim cryptoStream As CryptoStream
Dim position As Long
Dim ength As Long
Dim storage12 As 3yte
Dim 'ytes(ead As Integer
Dim cea As CryptoEventArgs
Dim header As String
If 'uFerSi.e : ? Then 'uFerSi.e : =;8
If inFie Is %othing 4rEse inFie : ,, Then
Thro# %e# Argument%uE"ception1,inFie,& ,/inFie/ shoud not 'e %othing
1nu in C+2 or String*Empty*,2
End If
If outFie Is %othing 4rEse outFie : ,, Then
Thro# %e# Argument%uE"ception1,outFie,& ,/outFie/ shoud not 'e
%othing 1nu in C+2 or String*Empty*,2
End If
If pass#ord Is %othing 4rEse pass#ord : ,, Then
Thro# %e# Argument%uE"ception1,pass#ord,& ,/pass#ord/ shoud not 'e
%othing 1nu in C+2 or String*Empty*,2
End If
inStream : %e# I4*FieStream1inFie& I4*FieMode*4pen& I4*FieAccess*(ead&
I4*FieShare*%one& 'uFerSi.e G <?=9 B <2
Try
outStream : %e# I4*FieStream1outFie& I4*FieMode*4pen4rCreate&
I4*FieAccess*Erite& I4*FieShare*%one& 'uFerSi.e G <?=9 B <2
Catch e" As E"ception
/Cose the open streams 'efore thro#ing the e"ception*
inStream*Cose12
Thro# e"
End Try
If provider Is %othing Then provider : %e# (i6ndaeManaged
(eDim >ey1provider*Lega$eySi.es1?2*Ma"Si.e @ A B <2
(eDim storage1'uFerSi.e G <?=9 B <2
cea : %e# CryptoEventArgs
cea*StartTimeInterna : %o#
provider*3oc>Si.e : provider*Lega3oc>Si.es1?2*Ma"Si.e
pass#ord3ytes : Me*7ashStringTo3yteArray1pass#ord2
Array*Copy1pass#ord3ytes& >ey& >ey*Length2
provider*$ey : >ey
provider*-enerateI512
header : Me*7ashStringTo3ase89String1Convert*To3ase89String1pass#ord3ytes2
& Convert*To3ase89String1provider*I522*!ad(ight1<=C2 &
Convert*To3ase89String1provider*I52*!ad(ight1<=C2
If Type4f provider Is DESCryptoService!rovider Then
header &: ,?<,
EseIf Type4f provider Is (C=CryptoService!rovider Then
header &: ,?=,
EseIf Type4f provider Is TripeDESCryptoService!rovider Then
header &: ,?D,
EseIf Type4f provider Is (i6ndaeManaged Then
header &: ,?9,
End If
ength : inStream*Length
cea*3ytesTotaInterna : ength
outStream*Erite1ASCIIEncoding*ASCII*-et3ytes1header2& ?& header*Length2
cryptoStream : %e# CryptoStream1outStream& provider*CreateEncryptor12&
CryptoStreamMode*Erite2
Ehie position H ength
'ytes(ead : inStream*(ead1storage& ?& storage*Length2
position I: 'ytes(ead
cea*3ytesDoneInterna : position
cryptoStream*Erite1storage& ?& 'ytes(ead2
cea*EndTimeInterna : %o#
(aiseEvent Crypto!rogress1Me& cea2
If cea*Cance Then E"it Ehie
End Ehie
cryptoStream*FushFina3oc>12
cryptoStream*Cose12
cryptoStream*Cear12
outStream*Cose12
inStream*Cose12
provider*Cear12
cea*EndTimeInterna : %o#
(aiseEvent CryptoCompeted1Me& cea2
cea*Dispose12
End Su'
!u'ic Su' DecryptFie13y5a inFie As String& 3y5a outFie As String& 3y5a pass#ord As
String2
Me*DecryptFie1inFie& outFie& pass#ord& ?2
End Su'
!u'ic Su' DecryptFie13y5a inFie As String& 3y5a outFie As String& 3y5a pass#ord As
String& 3y5a 'uFerSi.e As Integer2
Dim provider As SymmetricAgorithm
Dim pass#ord3ytes12 As 3yte
Dim >ey12 As 3yte
Dim inStream As I4*FieStream
Dim outStream As I4*FieStream
Dim cryptoStream As CryptoStream
Dim position As Long
Dim ength As Long
Dim storage12 As 3yte
Dim 'ytes(ead As Integer
Dim cea As CryptoEventArgs
Dim header1=;;2 As 3yte
Dim headerTe"t As String
If 'uFerSi.e : ? Then 'uFerSi.e : =;8
If inFie Is %othing 4rEse inFie : ,, Then
Thro# %e# Argument%uE"ception1,inFie,& ,/inFie/ shoud not 'e %othing
1nu in C+2 or String*Empty*,2
End If
If outFie Is %othing 4rEse outFie : ,, Then
Thro# %e# Argument%uE"ception1,outFie,& ,/outFie/ shoud not 'e
%othing 1nu in C+2 or String*Empty*,2
End If
If pass#ord Is %othing 4rEse pass#ord : ,, Then
Thro# %e# Argument%uE"ception1,pass#ord,& ,/pass#ord/ shoud not 'e
%othing 1nu in C+2 or String*Empty*,2
End If
inStream : %e# I4*FieStream1inFie& I4*FieMode*4pen& I4*FieAccess*(ead&
I4*FieShare*%one& 'uFerSi.e G <?=9 B <2
Try
outStream : %e# I4*FieStream1outFie& I4*FieMode*4pen4rCreate&
I4*FieAccess*Erite& I4*FieShare*%one& 'uFerSi.e G <?=9 B <2
Catch e" As E"ception
/Cose the open streams 'efore thro#ing the e"ception*
inStream*Cose12
Thro# e"
End Try
(eDim storage1'uFerSi.e G <?=9 B <2
cea : %e# CryptoEventArgs
cea*StartTimeInterna : %o#
ength : inStream*Length
cea*3ytesTotaInterna : ength
position I: inStream*(ead1header& ?& header*Length2
headerTe"t : ASCIIEncoding*ASCII*-etString1header2
Seect Case headerTe"t*Su'string1headerTe"t*Length B =2
Case ,?<,
provider : %e# DESCryptoService!rovider
Case ,?=,
provider : %e# (C=CryptoService!rovider
Case ,?D,
provider : %e# TripeDESCryptoService!rovider
Case ,?9,
provider : %e# (i6ndaeManaged
End Seect
(eDim >ey1provider*Lega$eySi.es1?2*Ma"Si.e @ A B <2
provider*3oc>Si.e : provider*Lega3oc>Si.es1?2*Ma"Si.e
pass#ord3ytes : Me*7ashStringTo3yteArray1pass#ord2
Array*Copy1pass#ord3ytes& >ey& >ey*Length2
provider*$ey : >ey
provider*I5 : Convert*From3ase89String1headerTe"t*Su'string1<=C& <=C2*Trim2
If %ot headerTe"t*Su'string1?& <=C2*Trim :
Me*7ashStringTo3ase89String1Convert*To3ase89String1pass#ord3ytes2 &
Convert*To3ase89String1provider*I522 Then
/If the pass#ord is incorrect& do some cean up 'efore thro#ing an
e"ception*
inStream*Cose12
outStream*Cose12
cea*Dispose12
provider*Cear12
Thro# %e# ArgumentE"ception1,The pass#ord speci)ed is invaid*,2
End If
cryptoStream : %e# CryptoStream1outStream& provider*CreateDecryptor&
CryptoStreamMode*Erite2
Ehie position H ength
'ytes(ead : inStream*(ead1storage& ?& storage*Length2
position I: 'ytes(ead
cea*3ytesDoneInterna : position
cryptoStream*Erite1storage& ?& 'ytes(ead2
cea*EndTimeInterna : %o#
(aiseEvent Crypto!rogress1Me& cea2
If cea*Cance Then E"it Ehie
End Ehie
cryptoStream*FushFina3oc>12
cryptoStream*Cose12
cryptoStream*Cear12
outStream*Cose12
inStream*Cose12
provider*Cear12
cea*EndTimeInterna : %o#
(aiseEvent CryptoCompeted1Me& cea2
cea*Dispose12
End Su'
!u'ic Function 7ashFieTo3ase89String13y5a )e As String2 As String
(eturn Me*7ashFieTo3ase89String1)e& %othing& ?2
End Function
!u'ic Function 7ashFieTo3ase89String13y5a )e As String& 3y5a provider As
7ashAgorithm2 As String
(eturn Me*7ashFieTo3ase89String1)e& provider& ?2
End Function
!u'ic Function 7ashFieTo3ase89String13y5a )e As String& 3y5a provider As
7ashAgorithm& 3y5a 'uFerSi.e As Integer2 As String
Dim )eStream As I4*FieStream
Dim output As String
Dim position As Long
Dim ength As Long
Dim storage12 As 3yte
Dim retStorage12 As 3yte
Dim 'ytes(ead As Integer
Dim cea As CryptoEventArgs
If 'uFerSi.e : ? Then 'uFerSi.e : =;8
If )e Is %othing 4rEse )e : ,, Then
Thro# %e# Argument%uE"ception1,)e,& ,/)e/ shoud not 'e %othing 1nu
in C+2 or String*Empty*,2
End If
)eStream : %e# I4*FieStream1)e& I4*FieMode*4pen& I4*FieAccess*(ead&
I4*FieShare*%one& 'uFerSi.e G <?=9 B <2
If provider Is %othing Then provider : %e# S7A;<=Managed
(eDim storage1'uFerSi.e G <?=9 B <2
(eDim retStorage1'uFerSi.e G <?=9 B <2
cea : %e# CryptoEventArgs
cea*StartTimeInterna : %o#
ength : )eStream*Length
cea*3ytesTotaInterna : ength
Ehie position H ength
'ytes(ead : )eStream*(ead1storage& ?& storage*Length2
position I: 'ytes(ead
cea*3ytesDoneInterna : position
If %ot position : ength Then
provider*Transform3oc>1storage& ?& 'ytes(ead& retStorage& ?2
Ese
provider*TransformFina3oc>1storage& ?& 'ytes(ead2
End If
cea*EndTimeInterna : %o#
(aiseEvent Crypto!rogress1Me& cea2
If cea*Cance Then E"it Ehie
End Ehie
)eStream*Cose12
If %ot cea*Cance Then output : Convert*To3ase89String1provider*7ash2
provider*Cear12
cea*EndTimeInterna : %o#
(aiseEvent CryptoCompeted1Me& cea2
cea*Dispose12
(eturn output
End Function
!u'ic Su' 4ver#riteFie13y5a )e As String2
Me*4ver#riteFie1)e& ?& True2
End Su'
!u'ic Su' 4ver#riteFie13y5a )e As String& 3y5a 'uFerSi.e As Integer2
Me*4ver#riteFie1)e& 'uFerSi.e& True2
End Su'
!u'ic Su' 4ver#riteFie13y5a )e As String& 3y5a deeteFie As 3ooean2
Me*4ver#riteFie1)e& ?& deeteFie2
End Su'
!u'ic Su' 4ver#riteFie13y5a )e As String& 3y5a 'uFerSi.e As Integer& 3y5a deeteFie
As 3ooean2
Dim )eStream As I4*FieStream
Dim position As Long
Dim ength As Long
Dim storage12 As 3yte
Dim cea As CryptoEventArgs
Dim )es As Fies
Dim random%um'er-enerator As (andom%um'er-enerator
If 'uFerSi.e : ? Then 'uFerSi.e : =;8
If )e Is %othing 4rEse )e : ,, Then
Thro# %e# Argument%uE"ception1,)e,& ,/)e/ shoud not 'e %othing 1nu
in C+2 or String*Empty*,2
End If
If deeteFie Then
)es : %e# Fies
)eStream : )es*4penFieForSecure4ver#rite1)e2
Ese
)eStream : %e# I4*FieStream1)e& I4*FieMode*4pen& I4*FieAccess*Erite&
I4*FieShare*%one& 'uFerSi.e2
End If
If )eStream Is %othing Then
Thro# %e# I4*I4E"ception1,The )e coud not 'e opened for over#riting*,2
End If
random%um'er-enerator : random%um'er-enerator*Create
(eDim storage1'uFerSi.e G <?=9 B <2
cea : %e# CryptoEventArgs
cea*StartTimeInterna : %o#
ength : )eStream*Length
cea*3ytesTotaInterna : ength
Ehie position H ength
If ength B position H storage*Length Then
(eDim storage1Convert*ToIntD=1ength B position B <22
End If
random%um'er-enerator*-et3ytes1storage2
)eStream*Erite1storage& ?& storage*Length2
position I: storage*Length
cea*3ytesDoneInterna : position
cea*EndTimeInterna : %o#
(aiseEvent Crypto!rogress1Me& cea2
If cea*Cance Then E"it Ehie
End Ehie
)eStream*Cose12
If %ot )es Is %othing Then )es*Dispose12
If deeteFie AndAso %ot cea*Cance Then I4*Fie*Deete1)e2
cea*EndTimeInterna : %o#
(aiseEvent CryptoCompeted1Me& cea2
cea*Dispose12
End Su'
+End (egion
End Cass
Imports System*I4
Imports System*(untime*InteropServices
Friend Cass Fies
Impements IDisposa'e
+(egion ,-o'a varia'es and initiai.ation,
/Add your go'a varia'es here*
!rivate Jopen7ande As Int!tr : Int!tr*Kero
!rivate Const I%5ALIDJ7A%DLEJ5ALUE As Integer : B<
!rivate Enum FieAccess
-E%E(ICJ(EAD : &7A???????
-E%E(ICJE(ITE : &79???????
-E%E(ICJELECUTE : &7=???????
-E%E(ICJALL : &7<???????
End Enum
!rivate Enum FieShare
FILEJS7A(EJ(EAD : &7<
FILEJS7A(EJE(ITE : &7=
FILEJS7A(EJDELETE : &79
End Enum
!rivate Enum CreationDisposition
C(EATEJ%EE : <
C(EATEJALEAMS : =
4!E%JELISTI%- : D
4!E%JALEAMS : 9
T(U%CATEJELISTI%- : ;
End Enum
!rivate Enum FagsAndAttri'utes
FILEJFLA-JE(ITEJT7(4U-7 : &7A???????
FILEJFLA-J45E(LA!!ED : &79???????
FILEJFLA-J%4J3UFFE(I%- : &7=???????
FILEJFLA-J(A%D4MJACCESS : &7<???????
FILEJFLA-JSENUE%TIALJSCA% : &7A??????
FILEJFLA-JDELETEJ4%JCL4SE : &79??????
FILEJFLA-J3AC$U!JSEMA%TICS : &7=??????
FILEJFLA-J!4SILJSEMA%TICS : &7<??????
FILEJFLA-J4!E%J(E!A(SEJ!4I%T : &7=?????
FILEJFLA-J4!E%J%4J(ECALL : &7<?????
End Enum
HDImport1,$erneD=*d,2O J
!rivate Shared Function CreateFie13y5a pFie%ame As String& 3y5a d#DesiredAccess As
FieAccess& 3y5a d#ShareMode As FieShare& 3y5a pSecurityAttri'utes As Integer& 3y5a
d#CreationDisposition As CreationDisposition& 3y5a d#FagsAndAttri'utes As FagsAndAttri'utes&
3y5a hTempateFie As Integer2 As Int!tr
End Function
HDImport1,$erneD=*d,2O J
!rivate Shared Function Cose7ande13y5a h4'6ect As Int!tr2 As Integer
End Function
/Customi.e Su' %e# for your re0uirements*
Friend Su' %e#12
End Su'
+End (egion
+(egion ,IDisposa'e impementation and reated code,
/%ormay this su' can 'e eft as is*
Friend 4veroads Su' Dispose12 Impements IDisposa'e*Dispose
Dispose1True2
-C*SuppressFinai.e1Me2
End Su'
!rotected 4verrida'e 4veroads Su' Dispose13y5a disposing As 3ooean2
If disposing Then
/Free managed o'6ects*
End If
/Free unmanaged o'6ects*
/Set arge )eds to nu*
If %ot Jopen7ande*E0uas1Int!tr*Kero2 AndAso %ot Jopen7ande*ToIntD= :
Me*I%5ALIDJ7A%DLEJ5ALUE Then
Me*Cose7ande1Jopen7ande2
Jopen7ande : Int!tr*Kero
End If
End Su'
/%ormay this su' can 'e eft as is*
!rotected 4verrides Su' Finai.e12
Dispose1Fase2
End Su'
+End (egion
+(egion ,Cass speci)c code,
Friend Function 4penFieForSecure4ver#rite13y5a path As String2 As FieStream
If %ot Jopen7ande*E0uas1Int!tr*Kero2 AndAso %ot Jopen7ande*ToIntD= :
Me*I%5ALIDJ7A%DLEJ5ALUE Then
Me*Cose7ande1Jopen7ande2
Jopen7ande : Int!tr*Kero
End If
Jopen7ande : Me*CreateFie1path& FieAccess*-E%E(ICJE(ITE&
FieShare*FILEJS7A(EJ(EAD 4r FieShare*FILEJS7A(EJE(ITE& %othing&
CreationDisposition*4!E%JELISTI%-& FagsAndAttri'utes*FILEJFLA-JE(ITEJT7(4U-7& %othing2
If Jopen7ande*ToIntD= : Me*I%5ALIDJ7A%DLEJ5ALUE Then
(eturn %othing
Ese
(eturn %e# FieStream1Jopen7ande& I4*FieAccess*(eadErite2
End If
End Function
+End (egion
End Cass

S-ar putea să vă placă și