الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

الرجاءالمساعدة في مشروع التخرج

بدأه allin في 17 فبراير 2011 · 3 رد · 538 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

البرنامج الاول عبارة عن برنامج للتشفير ب otp لكن كيف يمكن ان اخذ المفتاح من الparallport ارجو من خبراء البرمجة مساعدتي في مشروع التخرج بكتابة الاكواد المعدلة

 
#include <iostream>			//Standard C++ I/O.  Used for debugging mainly.  Could be done away with.
#include <time.h>			//Allows a Cish way to seed the rand() function with the timer
#include <fstream>			//Standard file usage.

using namespace std;		//Standard Namespace.

typedef char filename[80];	//The path+filenames of the files used

//MACROS

//This is just a nice way to do a XOR operation in code.
#define xor ^

//This allows a specific random range of int values.  Another VisC++ copy-paste.
#define getrandom(min, max) \
    ((rand()%(int)(((max)+1)-(min)))+(min))

//BEGIN MAIN PROGRAM
int main()
{
	unsigned char CharSizedChunk;		//A char sized chunk of data.
	unsigned char keys;					//The character that will make up the pad.

	//The file names
	filename InFileName = "";			//File to be encrypted
	filename EncryptName = "encrypted.dat";	//The encrypted file from the InFile
	filename PadName = "key.dat";		//The pad of keys to unencrypt the data

	fstream InFile, outPad, outEncrypt;	//The actual files.

	cout << "Please type in the name (and location) of the file you want to encrypt:\n ";
	cin  >> InFileName;

	try
	{
		//The file to encrypt
		InFile.open(InFileName,ios::in | ios::binary);		//Input from the file to encrypt
		if(!InFile) 				//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << InFileName << '\"' << " Did Not Open!!!\n\n";	//Ends in error.

		//Pad info
		outPad.open(PadName,ios::out | ios::binary);			//Output to the pad file
		if(!outPad) 				//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << PadName << '\"' << " Did Not Open!!!\n\n";		//Ends in error.

		//The encrypted file
		outEncrypt.open(EncryptName,ios::out | ios::binary);	//Output to an encypted version of the input file
		if(!outEncrypt) 			//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << EncryptName << '\"' << " Did Not Open!!!\n\n";	//Ends in error.
	}
	catch( ... )	//Arbitrary net
	{
		return (system("pause"));
	}
	InFile.seekg(0);			//Sets the filepointer to the begining of the file

//The Encryption stuff
	cout << "\n\n~Encrypting the Bytes~\n\n";	//An unnecessary title

	srand( (unsigned)time( NULL ) );	//Radomize using the computer's system timer as a seed value

	//Reads byte sized (ie ASCII character) chunks.  Literally reads the input file one char at a time.
	while( InFile.read((char *) & CharSizedChunk, sizeof (unsigned char)) )
	{
	  //cout << CharSizedChunk;						//More debugging output
		keys = unsigned char(getrandom(32,126));	//Makes the so called "pad."
		CharSizedChunk = CharSizedChunk ^ keys;		//XOR's the char with the randomly generated key.
	  //cout << CharSizedChunk;						//ECHOs the encrytion onto the screen; again debug usage
		outPad.write((char *) & keys, sizeof (unsigned char));	//Writes a char to the pad file
		outEncrypt.write((char *) & CharSizedChunk, sizeof (unsigned char));	//Writes a char to the encrypted file
	}

	//Closes the files out.
	outPad.close();outPad.clear();
	outEncrypt.close();outEncrypt.clear();
	InFile.close();InFile.clear();

	cout << "\n\nSome Helpful Hints ...\n"
		 << "*Only use the pad generated once.\n"
		 << "*Make sure you means of delivering the pad are secure!\n"
		 << "*When you run the Unencryption Software ... all you need is the \"xxx.dat"
		 << "\"\n and \"pad.dat\" to generate an \"out.dat\" file which is your Unencrypted file.\n\n";
	return (system("pause")); //return 0;
}
//END MAIN PROGRAM

البرنامج الثاني عبارة عن برنامج فك للتشفير ب otp لكن كيف يمكن ان اخذ المفتاح من الparallport ارجو من خبراء البرمجة مساعدتي

#include <iostream>			//Standard C++ I/O.  Used for debugging.
#include <time.h>			//Allows a Cish way to seed the rand() function with the timer
#include <fstream>			//Standard file usage.

using namespace std;		//Standard Namespace.

typedef char filename[80];	//The path+filenames of the files used

//MACROS

//This is just a nice way to do a XOR operation in code.
#define xor ^

//BEGIN MAIN PROGRAM
int main()
{
	unsigned char CharSizedChunk;			//A char sized chunk of data.
	unsigned char keys;						//The character that will make up the pad.

	//The file names
	filename OutFileName = "Decrypted.dat";		//File made from the encrypted file
	filename EncryptName = "Encrypted.dat";		//The encrypted file from the InFile
	filename PadName = "key.dat";			//The pad of keys to unencrypt the data

	fstream inPad, inEncrypt, outDecrypt;	//The actural file instances

	try
	{
		//Opens the One Time Pad file for input
		inPad.open(PadName,ios::in | ios::binary);		//Input from the pad file
		if(!inPad)		//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << PadName << '\"' << " Did Not Open!!!\n\n";//Ends in error.

		//Opens the Encrypted file for input
		inEncrypt.open(EncryptName,ios::in | ios::binary);//Input from the encrypted file
		if(!inEncrypt)	//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << EncryptName << '\"' << " Did Not Open!!!\n\n";//Ends in error.

		outDecrypt.open(OutFileName,ios::out | ios::binary);//The output file, decrypted
		if(!outDecrypt)	//Throws a Abort, Retry, Ignore error for the OS to take over
			throw cerr << "The File \"" << OutFileName << '\"' << " Did Not Open!!!\n\n";//Ends in error.
	}
	catch( ... )
	{
		return (system("pause")); //return 0;
	}

	inEncrypt.seekg(0);			//Sets the filepointer to the begining of the file
	inPad.seekg(0);				//Sets the filepointer to the begining of the file

//The Unencryption Half
	cout << "\n\n~Unencrypting the Bytes~\n\n";	//Another debugging title

	//Goes through the encrypted file, and the pad one char at a time.
	while(inEncrypt.read((char *) & CharSizedChunk, sizeof(unsigned char)) )
	{		
		//Reads the encryption
		inPad.read((char *) & keys, sizeof(unsigned char));

		//Unencrypts
		CharSizedChunk = CharSizedChunk ^ keys;

		//Final string writting
		// Kills the extra carrage returns ... an unusual symptom.  No doubt Visual C++.
		if( (int(CharSizedChunk) != 13) ) //Text editors fill in carrage returns at line feeds anyways
		{
		  //cout << CharSizedChunk << ' ';	//ECHOs the decrytion onto the screen
			outDecrypt.write((char *) & CharSizedChunk, sizeof(unsigned char));
		}
	}

//Makes sure everything is closed out.
	inPad.close();inPad.clear();
	inEncrypt.close();inEncrypt.clear();
	outDecrypt.close();outDecrypt.clear();

	cout << "\n\n";
	return (system("pause")); //return 0;
}
//END MAIN PROGRAM
#2

اين الردود يا اعضاء و هل في مبرمج موهوب يحل مشكلتى :unsure: :unsure: :unsure: :unsure: :unsure:

#3

السلام عليكم ورحمة الله وبركاته

استخدم المكتبة inpout32.dll (في حال ويندوز XP وما فوق)

راجع المثال: http://www.codeproject.com/KB/cs/csppleds.aspx

السلام عليكم ورحمة الله وبركاته.

#4

اذا ممكن كتابة الكود او اضافة فاكشن بلغة c++الي تاخذ المفاح من parallport

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…