Total members 11895 |It is currently Thu Dec 05, 2024 8:17 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





encryption/ decryption without key using C++
cpp code
#include<iostream>//for cin , cout.
using namespace std;
#include<iomanip>// for setw().
#include<windows.h>//for set_color(); ,clear_screen();.
#include<conio.h>//for getche().

int main()// main function.
{
char enc[2000];//the string for the text.
int count,i,j;//for loop counter.
char choise,cho='y';//do while variable.
char temp;
do
{
cout<<setw(40)<<"Enter the text which you want to encrypt: \n\n\t";
if(cin.peek() == '\n')
cin.get(); // add this line
cin.get(enc, 2000);
cout<<setw(20)<<"(e) to encrypt .\n(d) to decrypt .\n(x) to exit.\n\a ";
cin>>choise;
if(choise=='e'||choise=='E')
{

for(i=0,j=strlen(enc)-1;i<strlen(enc)/2;i++,j--)
{

temp=enc[j];
enc[j]=enc[i];
enc[i]=temp;
}

for(count=0;count<strlen(enc);count++)
{
if(enc[count]+count>255)
enc[count]=enc[count]-255+count;
else
enc[count]+=count;
}

cout << "Encrypted Text is: " << enc << endl;

}
else if(choise=='x'||choise=='X')
return 0;
else if(choise=='d'||choise=='D')
{



for(count=1;count<strlen(enc);count++)
{
if(enc[count]-count<0)
enc[count]=enc[count]+(255-count);
else
enc[count]-=count;
}

for(i=0,j=strlen(enc)-1;i<strlen(enc)/2;i++,j--)
{

temp=enc[i];
enc[i]=enc[j];
enc[j]=temp;
}
cout<<enc<<endl;
}
else
{
cout<<"please ,enter :\n(e) to encrypt .\n(d) to decrypt .\n(x) to exit.\n ";
}
cout<<"Do you want to continue?(y/n) ";
cin>>cho;
}while((cho=='y')||(cho=='Y'));

return 0;
}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : encryption/ decryption without key using C++
 Encryption and Decryption encryption Affine cipher code     -  
 encryption and decryption in c++     -  
 codes for encryption/decryption algorithms     -  
 Row Transposition cipher - encryption-decryption Csharp(C#)     -  
 Row Transposition cipher - encryption-decryption java     -  
 RSA encryption decryption cipher algorithm java     -  
 Ceasar encryption-decryption-cipher-decipher code     -  
 Encryption Algorithm{Data Encryption Standard}     -  
 ENCRYPTION TECHNIQUE     -  
 Encryption decoding     -  



Topic Tags

C++ Algorithms
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com