السلام عليكم و رحمة الله و بركاته اساتذتي اخواني اخواتي ^_^
ادعو الله ان تكونوا بخير و عافية انا الحمد لله في احسن الاحوال بعد الاختبارات
اليوم اردت ان اكتب هذا الموضوع البسيط عن شيفرة موريس و ما اعرفه عنها و فيه اردت ان اطرح بعض الاسئلة عن ما اجهله فيها
اولا :
من يكون موريس؟ :
هو صامويل فينلي بريز مورس ( 27/4/1791 - 2/4/1872 ) مخترع امريكي فهو من اخترع التيليغراف، عمل رساما طوال حياته و لانه لم يلق الاهتمام الذي يستحقه عانى من الفقر في بداياته و عندما صنع اول نموذج للتيليغراف أحدث بهذا ثورة في مجال الاتصالات.
ماهي شيفرة موريس؟ :
شيفرة موريس و قد سميت نسبة لمن اوجدها تعتمد على التشفير بالاستبدال اي انه قد اوجد ابجدية خاصة به تشفر الابجدية التي نفهمها نحن و هي ترتكز على النقطة (.) و المطّة (-) اذ ان لكل حرف ما يقابله في هذه الشيفرة فمثلا
A : -.
0 : -----
و هذه هي الصورة التي توضح التشفير الخاص بالابجدية الانجليزية ( الفرنسية ) و الارقام :

كما لاحظت انا في الشيفرة فانه لا توجد علاقة تربط بين الانتقال من حرف الى حرف اي انه ان شفرنا A فانه لا يمكننا ايجاد علاقة انتقال الى B من شيفرة A او اي حرف اخر اما الارقام فلدينا 0 و شيفرته هي ( ----- ) و نلاحظ ان الانتقال الى الارقام التي تليه يتم باستبدال المطات بالنقاط و ذلك حسب العدد الذي نريد تشفيره فمثلا نريد تشفير 2 فاننا نستبدل مطتين بنقطتين فنحصل على تشفير 2
هذه الصورة ممكن تشرح اكثر :

و هكذا دواليك الى ان ننهي التشفير الخاص بالارقام، لكن عندما نصل الى 5 ( ..... ) فهنا نقوم باستبدال النقاط بالمطات حسب القيمة المطلقة للفرق بين الرقم المراد تشفيره و 5 مثل
5-9= 4- اي لتشفير 9 نستبدل |4-| ( أي 4 ) نقاط من البداية بـ 4 مطات
و هنا ملاحظة :
الارقام الاقل من 5 لتشفيرها نستبدل النقاط بمطات من الاخير
اما الارقام الاكبر من 5 لتشفيرها نستبدل النقاط بمطات من البداية
اي على حسب ما فكرت انا انه يمكن الاستفادة من تشفير 0 ( ----- ) و تشفير 5 ( ..... ) لايجاد علاقة تمكننا من تقصير الكود ( و انا لم اطبقها مع الاسف :( )
هذه الشيفرة بسيطة في وقتنا الآني لذلك سألت شخصا هو أكبر مني و يدرس البرمجة ايضا عن طرق اخرى لجعل شيفرة مورس أقوى و اكثر تعقيدا فاجابني بطرق جعلت رأسي يدور :wacko:
قال لي :
هناك طرق كثييرة لجعل هذه الشيفرة اكثر تعقيدا و من بينها :
الاشتقاق - عملية الرقم الثنائي المهمل - والرقم الثنائي المتمم - العملية المنطقية xor - والنظام السداسي عشر -الترميز الثنائي
هنا يأتي سؤالي و هو : كيف يتم جعل شيفرة مورس اكثر تعقيدا بهذه الطرق ؟ و ما هو شرحها ؟ فأنا لم افهم كيف يتم ذلك :(
لذلك ارجو من حضرتكم ان تفيدوني بمعرفتكم و تطلعوني على اي معلومة تفيدني هنا فالفضول قد تملّكني و هذا الشخص للان لم يجبني لانه منشغل
بالمناسبة هذا هو الكود الخاص بي لشيفرة مورس أرجو ان لاتفزعوا من كمّ الاسطر فهو كثير جدا :blush: و هو 306 سطر ( يا الهي )
استعملت القوائم في هذا الكود
ارجو ان تفيدوني باي انتقاد و تصحيح او تقليص للكود و ساكون لكم من الشاكرات :lol:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct liste
{
char alpha;
char cipher[6];
struct liste *ptrn;
}alphaCode;
typedef struct liste2
{
char num;
char cipher[6];
struct liste2 *ptrn;
}numCode;
alphaCode *init_l_A()
{
alphaCode *tete,*a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9,*a10,*a11,*a12,*a13,*a14,*a15,*a16,*a17,*a18,*a19,*a20,*a21,*a22,*a23,*a24,*a25,*a26;
tete=NULL;
a1=(alphaCode*)malloc(sizeof(alphaCode));
a1->alpha='z';
strcpy(a1->cipher,"--..");
a1->ptrn=tete;
tete=a1;
//******************************
a2=(alphaCode*)malloc(sizeof(alphaCode));
a2->alpha='y';
strcpy(a2->cipher,"-.--");
a2->ptrn=tete;
tete=a2;
//******************************
a3=(alphaCode*)malloc(sizeof(alphaCode));
a3->alpha='x';
strcpy(a3->cipher,"-..-");
a3->ptrn=tete;
tete=a3;
//******************************
a4=(alphaCode*)malloc(sizeof(alphaCode));
a4->alpha='w';
strcpy(a4->cipher,".--");
a4->ptrn=tete;
tete=a4;
//******************************
a5=(alphaCode*)malloc(sizeof(alphaCode));
a5->alpha='v';
strcpy(a5->cipher,"...-");
a5->ptrn=tete;
tete=a5;
//******************************
a6=(alphaCode*)malloc(sizeof(alphaCode));
a6->alpha='u';
strcpy(a6->cipher,"..-");
a6->ptrn=tete;
tete=a6;
//******************************
a7=(alphaCode*)malloc(sizeof(alphaCode));
a7->alpha='t';
strcpy(a7->cipher,"-");
a7->ptrn=tete;
tete=a7;
//******************************
a8=(alphaCode*)malloc(sizeof(alphaCode));
a8->alpha='s';
strcpy(a8->cipher,"...");
a8->ptrn=tete;
tete=a8;
//******************************
a9=(alphaCode*)malloc(sizeof(alphaCode));
a9->alpha='r';
strcpy(a9->cipher,".-.");
a9->ptrn=tete;
tete=a9;
//******************************
a10=(alphaCode*)malloc(sizeof(alphaCode));
a10->alpha='q';
strcpy(a10->cipher,"--.-");
a10->ptrn=tete;
tete=a10;
//******************************
a11=(alphaCode*)malloc(sizeof(alphaCode));
a11->alpha='p';
strcpy(a11->cipher,".--.");
a11->ptrn=tete;
tete=a11;
//******************************
a12=(alphaCode*)malloc(sizeof(alphaCode));
a12->alpha='o';
strcpy(a12->cipher,"---");
a12->ptrn=tete;
tete=a12;
//******************************
a13=(alphaCode*)malloc(sizeof(alphaCode));
a13->alpha='n';
strcpy(a13->cipher,"-.");
a13->ptrn=tete;
tete=a13;
//******************************
a14=(alphaCode*)malloc(sizeof(alphaCode));
a14->alpha='m';
strcpy(a14->cipher,"--");
a14->ptrn=tete;
tete=a14;
//******************************
a15=(alphaCode*)malloc(sizeof(alphaCode));
a15->alpha='l';
strcpy(a15->cipher,".-..");
a15->ptrn=tete;
tete=a15;
//******************************
a16=(alphaCode*)malloc(sizeof(alphaCode));
a16->alpha='k';
strcpy(a16->cipher,"-.-");
a16->ptrn=tete;
tete=a16;
//******************************
a17=(alphaCode*)malloc(sizeof(alphaCode));
a17->alpha='j';
strcpy(a17->cipher,".---");
a17->ptrn=tete;
tete=a17;
//******************************
a18=(alphaCode*)malloc(sizeof(alphaCode));
a18->alpha='i';
strcpy(a18->cipher,"..");
a18->ptrn=tete;
tete=a18;
//******************************
a19=(alphaCode*)malloc(sizeof(alphaCode));
a19->alpha='h';
strcpy(a19->cipher,"....");
a19->ptrn=tete;
tete=a19;
//******************************
a20=(alphaCode*)malloc(sizeof(alphaCode));
a20->alpha='g';
strcpy(a20->cipher,"--.");
a20->ptrn=tete;
tete=a20;
//******************************
a21=(alphaCode*)malloc(sizeof(alphaCode));
a21->alpha='f';
strcpy(a21->cipher,"..-.");
a21->ptrn=tete;
tete=a21;
//******************************
a22=(alphaCode*)malloc(sizeof(alphaCode));
a22->alpha='e';
strcpy(a22->cipher,".");
a22->ptrn=tete;
tete=a22;
//******************************
a23=(alphaCode*)malloc(sizeof(alphaCode));
a23->alpha='d';
strcpy(a23->cipher,"-..");
a23->ptrn=tete;
tete=a23;
//******************************
a24=(alphaCode*)malloc(sizeof(alphaCode));
a24->alpha='c';
strcpy(a24->cipher,"-.-.");
a24->ptrn=tete;
tete=a24;
//******************************
a25=(alphaCode*)malloc(sizeof(alphaCode));
a25->alpha='b';
strcpy(a25->cipher,"-...");
a25->ptrn=tete;
tete=a25;
//******************************
a26=(alphaCode*)malloc(sizeof(alphaCode));
a26->alpha='a';
strcpy(a26->cipher,".-");
a26->ptrn=tete;
tete=a26;
//******************************
return tete;
}
numCode *init_l_N()
{
numCode *tete,*a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9,*a10;
tete=NULL;
a1=(numCode*)malloc(sizeof(numCode));
a1->num='9';
strcpy(a1->cipher,"----.");
a1->ptrn=tete;
tete=a1;
//******************************
a2=(numCode*)malloc(sizeof(numCode));
a2->num='8';
strcpy(a2->cipher,"---..");
a2->ptrn=tete;
tete=a2;
//******************************
a3=(numCode*)malloc(sizeof(numCode));
a3->num='7';
strcpy(a3->cipher,"--...");
a3->ptrn=tete;
tete=a3;
//******************************
a4=(numCode*)malloc(sizeof(numCode));
a4->num='6';
strcpy(a4->cipher,"-....");
a4->ptrn=tete;
tete=a4;
//******************************
a5=(numCode*)malloc(sizeof(numCode));
a5->num='5';
strcpy(a5->cipher,".....");
a5->ptrn=tete;
tete=a5;
//******************************
a6=(numCode*)malloc(sizeof(numCode));
a6->num='4';
strcpy(a6->cipher,"....-");
a6->ptrn=tete;
tete=a6;
//******************************
a7=(numCode*)malloc(sizeof(numCode));
a7->num='3';
strcpy(a7->cipher,"...--");
a7->ptrn=tete;
tete=a7;
//******************************
a8=(numCode*)malloc(sizeof(numCode));
a8->num='2';
strcpy(a8->cipher,"..---");
a8->ptrn=tete;
tete=a8;
//******************************
a9=(numCode*)malloc(sizeof(numCode));
a9->num='1';
strcpy(a9->cipher,".----");
a9->ptrn=tete;
tete=a9;
//******************************
a10=(numCode*)malloc(sizeof(numCode));
a10->num='0';
strcpy(a10->cipher,"-----");
a10->ptrn=tete;
tete=a10;
//******************************
return tete;
}
void alpha_coding(alphaCode *tete,numCode *tete1,char *t)
{
int len,i;
alphaCode *P;
numCode *Q;
char c;
P=tete;
Q=tete1;
len=strlen(t);
c=t[0];
for(i=0;i<=len;i++)
{
c=tolower(c);
if(isalpha(c))
{
while(P!=NULL && c!=P->alpha)
{
P=P->ptrn;
}
if(c==P->alpha)
{
printf("%s",P->cipher);
}
c=t[i+1];
P=tete;
Q=tete1;
}
else if(isdigit(c))
{
while(Q!=NULL && c!=Q->num)
{
Q=Q->ptrn;
}
if(c==Q->num)
{
printf("%s",Q->cipher);
}
c=t[i+1];
Q=tete1;
P=tete;
}
else
{
printf("%c",c);
c=t[i+1];
P=tete;
Q=tete1;
}
}
}
main()
{
alphaCode *Morisse_Code_tete_A;
numCode *Morisse_Code_tete_N;
char word[100];
printf("\t\tThis simple code for encryption manner Morris\n\n");
printf("Enter the word please ^_^ :\n");
gets(word);
Morisse_Code_tete_A=init_l_A();
Morisse_Code_tete_N=init_l_N();
alpha_coding(Morisse_Code_tete_A,Morisse_Code_tete_N,word);
printf("\n\nThank you ^O^\nTake care ^_^.\n");
}استودعكم الله و ارجو ان تفيدوني بما تعرفون سواء انتقاد او نصيحة فأنا سائرة على طريق من سبقني و لابد لي من نصحكم حتى الحق بركبكم
بالتوفيق مع بالغ احترامي ^_^