Thursday, 25.04.2024, 17:44
Welcome Guest | RSS
Site menu
Login form
Section categories
Search
Calendar
«  June 2011  »
SuMoTuWeThFrSa
   1234
567891011
12131415161718
19202122232425
2627282930
Entries archive
Our poll
Rate my site
Total of answers: 6
Statistics

Total online: 1
Guests: 1
Users: 0

Main » 2011 » June » 10 » Encrypt-decrypt text
18:01
Encrypt-decrypt text
#include <iostream >
using std :: cout;
using std :: endl;
void encrypt( char [ ] ); // prototypes of functions used in the code
void decrypt( char * ePtr );
int main( )
{
// create a string to encrypt
char string[ ] = "this is a secret!";
cout << "Original string is: " << string << endl;
encrypt( string );
// call to the function encrypt( )
cout << "Encrypted string is: " << string << endl;
decrypt( string );
// call to the function decrypt( )
cout << "Decrypted string is: " << string << endl;
return 0;
}// main

//encrypt data
void encrypt (char e[] )
{
for( int i=0; e[i] != '\0'; ++i ) ++e[i];
} // encrypt

//decrypt data
void decrypt( char * ePtr ) {
for( ; * ePtr != '\0'; ++ ePtr ) --(* ePtr);
}

Category: C++ programs | Views: 552 | Added by: H_Imirzyan | Tags: encrypt-decrypt, text, encrypt, decrypt | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *: