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

التشفير لmono Alphabtic

بدأه مولا في 28 مارس 2008 · 4 رد · 540 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

كيفكم

بليز ابغى مساعدتكم في كود للتشفير سويته زبط معاي ربعه :D mono alphabtic

المطلوب اني اكتب الكلمة في ملف والتشفير في ملف تاني

انا سويت مصفوفه فاضيه علشان ادخل key ومصفوفه تانيه في الحروف الانكلش كلها فراح يقارن key

حروفها مع بعض والمتكرر يحذفوا ويخلي واحد دي زبطت معاي

أما لما اقارن حروف الكيه مع الحروف الانكلش عاشان يشيل المتكرر ويكمل على مصفوفة الكيه بالحروف اللي مش موجوده لما يصير فيها 26 حرف ماتزبط

ولما ادخل الكلمه علشان اشفرها ما يجي معاي فياليت اللي يقدر يساعدني :wub:

والكود

#include<iostream.h>

#include<fstream.h>

void read()

{

ofstream a("cipher.txt");

const int n=27;

char g[n];

a<<" the key is : "<<"the ciphertext ";

ifstream b("plaintext.txt");

{

a<<g[n];

b>>g[n];

b.close();}

a.close();

}

void write()

{

ofstream b("plaintext.txt");

char c,h,q;

const int n=27;

const int v=27;

char g[n];

char a[v]="abcdefghijklmnopqrstuvwxyz";

bool x=false;

////////////////////

cout<<"enter key:"<<endl;

cin.get(g,n,'$');

for(int i=0;i<n;i++)

{

for(int j=0;j<v;j++)

{

if(g==g[i+1])

{

g[i+1]--;

cout<<g;

b<<g;

}

if(g==a[j])

{

a[j]++;

cout<<g;

b<<g;

x=true;}

}

if(x==false)

cout<<g;

}

b.close();}

void main()

{

write();

read();

}

اسفه على الاطالة

تم تعديل هذه المشاركة بواسطة مولا في 28 مارس 2008 في 17:29

#2

الكود:

#include<iostream.h>
#include<fstream.h>

void read()
{
 ofstream a("cipher.txt");

 const int n = 27;
 char g[n];

 a<<"the key is: "<<"\nthe ciphertext: ";

 ifstream b("plaintext.txt");
  {
   a<<g[n];
   b>>g[n];
   b.close();
  }

 a.close();
}

void write()
{
 ofstream b("plaintext.txt");

 char c, h, q;
 const int n = 27;
 const int v = 27;
 char g[n];
 char a[v] = "abcdefghijklmnopqrstuvwxyz";
 bool x=false;

 cout<<"enter key: ";

 cin.get(g,n,'$');

 for(int i = 0; i < n; i++)
 {
  for(int j = 0; j < v; j++)
  {
   if(g == g[i+1])
   {
	g[i+1]--;
	cout<<g;
	b<<g;
   }
   if(g ==a [j])
   {
	a[j]++;
	cout<<g;
	b<<g;
	x=true;
   }
  }
  if(x == false)
   cout<<g;
 }
 b.close();
}

void main()
{
 write();
 read();
}

تم تعديل هذه المشاركة بواسطة da666ni في 28 مارس 2008 في 17:51

Chao!!!

Great place, and people, but full of sectarianism.

#3

ان شاء الله يكون واضح لاني بأحطه في المرفقات مو راضي وشكرا

#4

26 مشاهده ولا احد رد

يابخلاء :angry:

#5

السلام عليكم هذا كلاس ينفذ تقريبا كل المطلوب:

#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class my_cipher
{
public:
    string  encryption(string,int); 
    string  decryption(string,int);
    string  read_from_file(string);
    void    write_to_file(string,string);  
};
string my_cipher::encryption(string str,int key)  /*دالة تشفير */
{   string temp;
temp.resize(str.size() ); 
 for(int i=0;i<str.length();i++)
 {
     if(int(str)+ key <=int('z'))
     temp=(int(str)+ key );
     else                                                               
     temp=(int(str)+ key )-26;
 }
  return temp;
}

string my_cipher::decryption(string str, int key)/*فك التشفير*/
{      string temp;
temp.resize(str.size() );
for(int i=0;i<str.length();i++)
 {   if(int(str)- key >=int('a'))
     temp=(int(str)- key );
     else
     temp=(int(str)-key )+26;
 }
  return temp;}

void my_cipher::write_to_file(string str, string myfilename)/*دالة تكتب نص الى ملف*/
{ ofstream myfile;
  myfile.open(myfilename.c_str() );
  myfile << str.c_str()  <<endl;
  myfile.close();}

string my_cipher::read_from_file(string myfilename)/*دالة تقراء السطر من الملف*/
{string line;
  ifstream myfile (myfilename.c_str() );
  if (myfile.is_open())
     getline (myfile,line);
      myfile.close();
      return line;}

int main()
{
 my_cipher obj;
 string str;
 int key;
 cout<<"Enter Text  encryption:";
 getline(cin,str);
 cout<<"Enter key encryption:";
 cin>>key;
 cout<<"encryption: "<< obj.encryption(str,key)<<endl;
 obj.write_to_file(obj.encryption(str,key),"cipher.txt");
}
tvquran_6.gif

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