Project in ProLab (defense) C++

Started on the old forum in March 2010 · view the original in the archive · old links redirect here

6 replies · 616 views · started 16 years ago · 1 min read

2 participants
kiLLeR-eyEd_14 Senior · 382 posts #1

for a long time i'm not asking for a help here..here i am now..asking for your help in our final project in programming..please help me how to encrypt and decrypt a text using C++..the encryption and decryption will base on a txt file called subtable which has a 2 column ascii conversion table..for further explanations, i repeat and explain it further..there is a file named subtable.txt..inside it is the conversion table of an upper and lower case letters, numbers and special characters..example:

A 100
B 200
C 300
1 009
2 008
3 007
! 1
@ 2
# 3
$ 4

only space will divide the character and its ascii character..then create a program that will encrypt and decrypt a text from an existing file for example named file.txt..it will be read using fopen() read mode and then using fputc() to put or write it on a text file which is now encrypted basing fom the subtable..then create a code now to decrypt the encrypted file which will have the same text with file.txt..thanks for those who will be attempting to help me..it would be much appreciated..thanks again..graduate students..pls help me..:)

wapmetal Lead · 609 posts #3

try my code

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

DONT FORGET TO CLICK THANKS

outpUT: original String: ----------------

Encrypted string is: uijt!jt!b!tfdsfu"

Decrypted string is: this is a secret!

try this

//Encrypt the text
string encrypt(string text, string message)
 
  		{
		int i;
   	string temp;
 
 
		cout << "Enter the text you wish to encrypt." << endl;
		cin >> text;
 
 
		for (i = 0; i < message.length(); ++i)
      temp = 3 + (text[i] - '0') ;
 
		cout << "Encrypted text is " << temp << endl;
 
		}
 
//Decrypt the text
string decrypt(string text, string message)
 
  		{
		int i;
   	string temp;
 
 
		cout << "Enter the text you wish to decrypt." << endl;
		cin >> text;
 
 
		for (i = 0; i < message.length(); ++i)
      temp = 3 + (text[i] - '0');
 
		cout << "Decrypted text is " << temp << endl;
		}

you dont need open source for getting ASCII or etc txt file for converting because theres a function in cpp that will do this thing LOL

DON't FORGET TO CLICK THANKS

kiLLeR-eyEd_14 Senior · 382 posts #4

i've also done this mate..encrypting and decrypting a text is very easy to do in my own way..but we need to follow what our prof instructed to do..we need to create a file named subtable.txt which has the conversion table like what i've previously posted..and this file should be read using fopen() read mode..a character will be read in the subtable and get its ascii code..then put that ascii code into a text file..that's the encrypted one..

kiLLeR-eyEd_14 Senior · 382 posts #6

it should be like this..the subtable.txt has a conversion tableformat is <character><space><ascii code> then break line..

A x0
B x1
C x2

then the program will read a file where that file contains a text to be encrypted to ascii code..it will also be decrypted by doing the process reversely..

kiLLeR-eyEd_14 Senior · 382 posts #7

Please try to look at my codes and read every comments i put there..I only type these with my phone..Dunno if it's running, but my only point is to further explain you my problem and hope you could help me with it..Especially those it graduates and higher level to me..I'm only first year college student..We're on visual c++..This is the link to my codes, please download and post the solved one..Thank you..

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close