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

مساعدة في تحليل كود تشفير بطريقة القيصر

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

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

كان عندي هذا الكود في جهازي من ضمن كتب و امثله اخدتها من صديق

طبعا برمجيتي بالسي بلس بلس مش قويه مره مره انما تمشي الحال و اتمنى ادرسها بشكل اكثر لانها ممتعه

حاليا ادرس مادة امن معلومات و التشفير و غيره و لقيت الكود هذا و حابب اعرف كيف يعمل بالضبط ليس باضافة المفتاح بل طريقة ظهور الناتج برموز لاتينيه و غيره

اتمنى من اهل الخبره تحليل الكود و شرحة و اضافة مراجع او دروس حول هذا الموضوع من اجل الاستفادة

رقم واحد

#include<iostream.h>
#include<conio.h>
main()
   {
   const int n=100;
   char a[n],x[n];
   int i=0;
   int k;
   cout<<"enter the string \n";
   cin.get(a,n);
   strcpy(x,a);
   cout<<"enter the space k ";
   cin>>k;
   while(k<'0'&&k>'9')
      {
      cout<<"error !!!\n"<<"enter the space k ";
      cin>>k;
      }
   for(i=0;a!='\0';i++)
      {
      a=a+k;
      if(a>255)
         {
         cout<<"error !\n"<<"enter new k";
         cin>>k;
         i=0;
         strcpy(a,x);
         }
      }
   cout<<a;
   cout<<"\npress any kay to exit ...";
   getch();
   }

رقم اثنين

#include<iostream.h>
#include<conio.h>
main()
   {
   const int n=100;
   char a[n];
   int i=0;
   char k;
   cout<<"enter the string \n";
   cin.get(a,n);
   cout<<"enter the space k ";
   cin>>k;
   while(k<48||k>57)
      {
      cout<<"error !!!\n"<<"enter the space k ";
      cin>>k;
      }
   for(i=0;a!='\0';i++)
      a=a+k;
   cout<<a;
   getch();
   }

و اتمنى في الاخير افادتنا بطريقة فك التشفير إن امكن

و شكرا للجميع

#2

الفهم من خلال مقارنة المخرجات:

الاول:

#include <iostream>
#include <cstdlib> //#include<conio.h>
#include <string.h>
using namespace std;

int main()
{
    const int n = 100;
    char a[n], x[n];
    int i = 0;
    int k;
    cout << "enter the string \n";
    cin.get(a, n);
    strcpy(x, a);
    cout << "enter the space k ";
    cin >> k;
    while (k < '0' && k > '9')
    {
        cout << "error !!!\n" << "enter the space k ";
        cin >> k;
    }
    for (i = 0; a != '\0'; i++)
    {
        a = a + k;
        if (a > 255)
        {
            cout << "error !\n" << "enter new k";
            cin >> k;
            i = 0;
            strcpy(a, x);
        }
    }
    cout << a;
    cout << "\npress any kay to exit ...";
}

مدخلات ومخرجات:

enter the string 
123
enter the space k 1
234
press any kay to exit ...

RUN SUCCESSFUL (total time: 8s)

الثانى:

/* 
 * File:   main.cpp
 * Author: Mohammed Abu Zayed
 * * Created on May 28, 2012, 6:55 AM
 */

#include <cstdlib>
#include <iostream>

using namespace std;

main()
{
    const int n = 100;
    char a[n];
    int i = 0;
    char k;
    cout << "enter the string \n";
    cin.get(a, n);
    cout << "enter the space k ";
    cin >> k;
    while (k < 48 || k > 57)
    {
        cout << "error !!!\n" << "enter the space k ";
        cin >> k;
    }
    for (i = 0; a != '\0'; i++)
        a = a + k;
    cout << a;

}

مخرجات:

enter the string 
123
enter the space k 1
bcd
RUN SUCCESSFUL (total time: 10s)

تقبل مرورى والله من وراء القصد:

تم تعديل هذه المشاركة بواسطة AudaNix في 28 مايو 2012 في 08:12

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

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

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

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

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

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