Sponsored Content
Operating Systems Linux Ubuntu i have a problem in programing of linux Post 302571022 by g.gupta3392 on Saturday 5th of November 2011 01:58:35 PM
Old 11-05-2011
covert this codig of linux

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);


Last edited by pludi; 11-05-2011 at 03:06 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Graphics programing

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)
Discussion started by: Sebastyan
1 Replies

2. Programming

Win programing

I am having a windows and i would like to know whitch program do you prefer for programing in windows P.S. C++ (1 Reply)
Discussion started by: D.Borak
1 Replies

3. Linux

Linux game programing or just shell scripting

Well Acording to my job... Anyhelp plz. I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies

4. HP-UX

crontab programing

How can program at crontab dayly each 30 minut (2 Replies)
Discussion started by: petroleo
2 Replies

5. Shell Programming and Scripting

Awk Programing (need help)

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)
Discussion started by: SoCalledEngr
1 Replies

6. Shell Programming and Scripting

shell programing...

Hi... i need to write a shell script wich shows the full name and station of every logged user in the system. pls help! (1 Reply)
Discussion started by: relu89
1 Replies

7. IP Networking

Netork programing

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)
Discussion started by: vin_pll
1 Replies

8. Programming

Unicode programing in C

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

socket programing-problem with server

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)
Discussion started by: chandinisree
1 Replies

10. IP Networking

socket programing-problem with server

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)
Discussion started by: chandinisree
1 Replies
All times are GMT -4. The time now is 10:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy