sir, please convert this coding according to ubuntu.after converting this coding they can run on ubuntu 10.05.
Code:
///**************************************************************************
// PROJECT: PRIVATE KEY CRYPTOGRAPHY
// DETAILS: USER ENTERED TEXT IS ENCRYPTED WITH THE
// PRIVATE KEY PROVIDED BY THE USER AND DECRYPTED
// ONLY IF THE SAME PRIVATE KEY IS ENTERED.
/***************************************************************************/
///*************************************************************************
// INCLUDED HEADER FILES
/***************************************************************************/
#include<stdio.h>
#include<iostream.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
////************************************************************************
/// CLASS :ENCRYPTION
// DETAILS:IT IS THE BASE CLASS CONTAINING ALL THE
// FUNCTIONS FOR ENCRYPTION OF ENTERED TEXT
/**************************************************************************/
class encryption
{
protected:
char *private_key;
char encry[100];
char password[10];
char temp[10];
int p,q,t;
public:
int i,j;
char array[100];
char text[100];
void gettext();
void show_encr_text();
void encrypt();
void hashing();
};
////*************************************************************************
/// CLASS: DECRYPTION
// DETAILS: IT IS PUBLICALY DERIVED FROM CLASS ENCRYPTION.
// IT CONTAINS ALL THE FUNCTOINS REQUIRED FOR
// DECRYPTION OF TEXT.
/****************************************************************************/
class decryption:public encryption
{ char *pass;
public:
void get_encr_text();
void decrypt();
void decr1();
void show_decr_txt();
};
////*****************************************************************************
/// FUNCTION NAME:GETTEXT()
// BELONGS TO CLASS ENCRYPTION
// DETAILS: IT TAKES THE TEXT TO BE ENCRYPTED BY THE USER AND
// THERE PRIVATE KEY.
/********************************************************************************/
void encryption::gettext()
{
cout<<"\n\n\nEnter text to be encrypted: \n"<<endl;
cin>>text;
private_key=getpass("Enter private key: \n");
cout<<endl;
}
////*******************************************************************************
/// FUNCTION NAME: ENCRYPT()
// BELONGS TO CLASS ENCRYPTION
// DETAILS: IT ENCRYPTS THE TEXT USING THE PRIVATE KEY
/**********************************************************************************/
void encryption::encrypt()
{ p=strlen(private_key);
t=strlen(text);
q=t/p;
for(i=0;i<t;i++)
{encry[i]=text[i]+7;
}
for(i=0;i<t;i++)
{array[i]=encry[t-i-1];}
for(i=0;i<t;i++)
{encry[i]=array[i];}
for(i=0,j=0;i<t,j<p;i=i+q+1,j++)
{ temp[j]=encry[i];
encry[i]=private_key[j];
}
}
////*******************************************************************************
/// FUNCTION NAME: SHOW_ENCR_TEXT()
// BELONGS TO CLASS ENCRYPTION
// DETAILS: IT SHOWS THE ENCRYPTED TEXT
/**********************************************************************************/
void encryption::show_encr_text()
{ cout<<"\nEncrypted text is: ";
for(i=0;i<t;i++)
{ cout<<encry[i];
}
}
////*******************************************************************************
/// FUNCTION NAME:GET_ENCR_TEXT()
// BELONGS TO CLASS DECRYPTION
// DETAILS:IT ASKS FOR PRIVATE KEY TO DECRYPT.
/**********************************************************************************/
void decryption::get_encr_text()
{
pass=getpass("\n\n\nEnter private key to decrypt: ");
}
////*******************************************************************************
/// FUNCTION NAME:DECR1()
// BELONGS TO CLASS DECRYPTION
// DETAILS:IF THE KEY ENTERED BY USER MATCHES WITH THE KEY
// OF ENCRYPTION,IT DECRYPTS THE DATA; OTHERWISE
// PRINTS A MESSAGE SAYING WRONG KEY.
//
/**********************************************************************************/
void decryption::decr1()
{
for(i=0,j=0;i<t,j<p;i=i+q+1,j++)
{
password[j]=encry[i];
encry[i]=temp[j];
}
cout<<" ";
cout<<" ";
// cout<<"tmp"<<temp;
for(i=0;i<t;i++)
{cout<<encry[i];}
/ cout<<"\n\n"<<pass;
if (strcmp(password,pass)==0)
{ cout<<" ";
decrypt();
}
else
cout<<"\nYOU ENTERED WRONG PRIVATE KEY";
}
////*******************************************************************************
/// FUNCTION NAME:DECRYPT()
// BELONGS TO CLASS DECRYPTION
// DETAILS:IT SHOWS THE DECRYPTED TEXT WHEN THE
// IS CORRECT.
/**********************************************************************************/
void decryption::decrypt()
{
for(i=0;i<t;i++)
{array[i]=encry[t-i-1];}
for(i=0;i<t;i++)
{encry[i]=array[i];}
for(i=0;i<t;i++)
{ text[i]=encry[i]-7;
}
cout<<"\n\nDecrypted text: "<<text;
hashing();
}
////*******************************************************************************
/// FUNCTION NAME:HASHING()
// BELONGS TO CLASS ENCRYPTION
// DETAILS:IT CALCULATES THE HASH VALUE OF TEXT.
/**********************************************************************************/
void encryption::hashing()
{
int counti=0,counta=0,counte=0,counto=0,countu=0,count=0,hash=0;
for(i=0;i<t;i++)
{
if(text[i]=='a')
counta++;
else if(text[i]=='i')
counti++;
else if(text[i]=='e')
counte++;
else if(text[i]=='o')
counto++;
else if(text[i]=='u')
countu++;
}
count=counta+counte+counti+counto+countu;
hash=(count/p)*17;
cout<<endl<<"Hash Value= "<<hash;
}
////*******************************************************************************
/// FUNCTION NAME:MAIN()
// DETAILS: MAIN FUNCTION....
/**********************************************************************************/
void main()
{ system("clear");
decryption E;
int choice;
char ch;
do
{
cout<<"\n\n\n\nEnter if u want to\n\n1.Encrypt \n\n2.Decrypt"<<endl;
cin>>choice;
switch(choice)
{
case 1:
E.gettext();
E.encrypt();
E.show_encr_text();
E.hashing();
break;
case 2:
E.get_encr_text();
E.decr1();
break;
default:
break;
}
cout<<"\n\n\n\nDo you wish to continue? y/n"<<endl;
cin>>ch;
}while(ch=='y'||ch=='Y');
char c;
cin.get(c);
Hi all!
I`m new in Unix (Linux) and i whant to ask something!
What language should i use for Linux developing.I meen applications an GAME DEVELOPING!
Should i use C,TCL ??? Please help me on this ...:( (1 Reply)
plx help to solve these problems??
1. Create a HERE document which will edit multiple files in the same directory, using the ed editor. I give you 3 original files: file1.c , file2.c , file3.c, download them and change each string "stdio.h" to "STDIO.H" in these files. Note: when execute the... (1 Reply)
Hello experts,
please help me as i want to learn the networking concepts in details ,
as i come know Unix network programming by Richard Stevens volume 1,2
is good please any of you downloaded the Free PDF version of it please direct m e as i want to download these books or the pdf form of it,... (1 Reply)
im starting to go a little serious with c, woking in a personal project that will read a xml, which might contain Unicode characters (i know it will on my system, which is set to es_AR.UTF-8)
im using mxml, and the documentation says it uses utf8 internally (no worries here).
so i need to be... (4 Replies)
Discussion started by: broli
4 Replies
9. Post Here to Contact Site Administrators and Moderators
hi,
i am new to socket programming.i have a problem in server.requirement is it should continuosly read the requests from client(sends requests continuously) and after certain delay(i kept der sleep) should send response.
for this i used msgqueues so that after reading it is sending into... (1 Reply)
hi,
i am new to socket programming.i have a problem in server.requirement is it should continuosly read the requests from client(sends requests continuously) and after certain delay(i kept der sleep) should send response.
for this i used msgqueues so that after reading it is sending into... (1 Reply)