Information Security Project Report
Information Security Project Report
Group Project
1 Introduction
Cryptography is the study and practice of methods for secure communication in the presence of outside parties. Generally, it is about creating and examining protocols that overcome the aect of rivals and which are related to numerous aspects in information security such as (CIA) data condentiality, data integrity, authentication, and non-repudiation. Modern cryptography combines the disciplines of Computer Science, Mathematics and Electrical Engineering. Applications of cryptography include Internet communication, computer passwords, electronic commerce and mobile privacy.
There are two major types of Cryptography currently in use today. The rst is private-key cryptography in which both the sender and recipient have a key which they obtain securely and which they use to encrypt and decrypt the data between them. The second is publickey cryptography which requires two keys, one private and one public. One key is used for encrypting data while the other is used for decryption, however, none of them can be used for both functions. The project attempts to simulate how a private-key cryptography would work in real life by creating a program in C++.
3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
The Program
#include < c s t d l i b > #include < c s t d i o > #include < i o s t r e a m > #include < s t r i n g > // This l i b r a r y i s used as we need t o use S t r i n g t y p e . // system ( c l s ) ; using namespace s t d ; int main ( ) { // Array t o c o n t a i n t h e l e t t e r s o f t h e a l p h a b e t , b o t h upper and l o w e r case . char s m a l l [ 2 6 ] = { a , b , c , d , e , f , g , h , i , j , k , l , m , n , o , p , q , r , s , t , u , v , w , x , y , z } ; char b i g [ 2 6 ] = { A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z } ; // Array t o c o n t a i n l e t t e r s which c o r r e s p o n d t o t h e o r i g i n a l l e t t e r s of the alphabet a l p h a b e t i c a l l y . char s m a l l c r y p t [ 2 6 ] = { z , y , x , w , v , u , t , s , r , q , p , o , n , m , l , k , j , i , h , g , f , e , d , c , b , a } ; char b i g c r y p t [ 2 6 ] = { Z , Y , X , W , V , U , T , S , R , Q , P , O , N , M , L , K , J , I , H , G , F , E , D , C , B , A } ; // D e c l a r e v a r i a b l e t o use f o r u s e r i n p u t . char s e n t e n c e [ 1 0 0 ] ; // D e c l a r e v a r i a b l e t o s t o r e e n c r y p t e d S t r i n g . char e n c r y p t [ 1 0 0 ] ; // D e c l a r e v a r i a b l e t o s t o r e d e c r y p t e d S t r i n g . char d e c r y p t [ 1 0 0 ] ; // V a r i a b l e t o c o n t r o l menu int menu=0; cout << \ n \ t \ t \ t \tCRYPTOGRAPHY SYSTEM\ n<< e n d l ; cout << \ tMenu : \ n<< e n d l ; cout << \ t [ 1 ] Encrypt a s t r i n g . \ n<< e n d l ; cout << \ t [ 2 ] Decrypt a s t r i n g . \ n<< e n d l ; cout << \ t [ 3 ] E x i t \ n<< e n d l ; do { cout << \ n \ t E n t e r c h o i c e : ; c i n >>menu ; fflush ( stdin ) ; } while ( ( menu < 1) | | ( menu > 4) ) ; // v e r i f i e s i n p u t i s i n t h e range , 1 4. switch ( menu )
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
{ case ( 1 ) : { string str ; cout << \ n \ t E n t e r s t r i n g t o e n c r y p t ( 1 0 0 c h a r a c t e r s ) : ; g e t l i n e ( cin , s t r ) ; fflush ( stdin ) ; string str encrypt = str ; int i =0, j =0; f o r ( i =0; i < s t r . l e n g t h ( ) ; i ++) { f o r ( j =0; j < 26; j ++) { i f ( s t r [ i ]== s m a l l [ j ] ) str encrypt [ i ] = smallcrypt [ j ] ; i f ( s t r [ i ]== b i g [ j ] ) s t r e n c r y p t [ i ]= b i g c r y p t [ j ] ; } } cout << \ n \ t S t r i n g e n c r y p t e d becomes : << s t r e n c r y p t ; break ; } case ( 2 ) : { string str ; cout << \ n \ t E n t e r s t r i n g t o e n c r y p t ( 1 0 0 c h a r a c t e r s ) : ; g e t l i n e ( cin , s t r ) ; fflush ( stdin ) ; string str decrypt = str ; int i =0, j =0; f o r ( i =0; i < s t r . l e n g t h ( ) ; i ++) { f o r ( j =0; j < 26; j ++) { i f ( s t r [ i ] == s m a l l c r y p t [ j ] ) str decrypt [ i ] = small [ j ] ; i f ( s t r [ i ] == b i g c r y p t [ j ] ) str decrypt [ i ] = big [ j ] ; } } cout << \ n \ t S t r i n g d e c r y p t e d becomes : << s t r d e c r y p t ; break ; } case ( 3 ) : } return 0 ; } return 0 ; break ;