SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
1- Given an input key ABCDEF0123456789H, and the plaintext 0123456789ABCDEFH,
     perform a one round encryption using DES. Show intermediate results after each
     function.

  Solution:

      Calculations for the first subkey k1:
  -

Input key: ABCDEF0123456789H

                               (TABLE 1-1) Input key 64 bits
                       1        0   1     0     1     0        1       1
                       1        1   0     0     1     1        0       1
                       1        1   1     0     1     1        1       1
                       0        0   0     0     0     0        0       1
                       0        0   1     0     0     0        1       1
                       0        1   0     0     0     1        0       1
                       0        1   1     0     0     1        1       1
                       1        0   0     0     1     0        0       1


                     (TABLE 1-2) Permuted Choice one (PC-1) [56 bits]
                         1    0     0    0     0     1     1
                         1    0     1    1     0     0     1
                         1    0     0    1     0     1     0
                         1    0     1    0     0     0     0

                           0      1     0     1     0     1        0
                           1      0     1     1     0     0        1
                           1      0     1     0     0     0        0
                           1      1     1     0     0     0        0


        (TABLE 1-3) Left Shift by 1 (for round 1) for each 32 bits [C0 D0] separately
                       0      0      0     0      1     1     1
                       0      1      1     0      0     1     1
                       0      0      1     0      1     0     1
                       0      1      0     0      0     0     1

                           1      0     1     0     1     0        1
                           0      1     1     0     0     1        1
                           0      1     0     0     0     0        1
                           1      1     0     0     0     0        0
(TABLE 1-4)Permuted Choice Two (Pc-2) [48 bits Subkey K1]
               1      1      0       0     0       1      0     1
               0      1      1       1     1       1      0     0
               0      0      0       1     0       0      1     0
               1      0      1       1     0       0      0     0
               1      0      1       0     1       1      0     0
               0      0      0       1     1       0      1     0
            Converting LAST table to Hexadecimal yields: C57C12B0AC1AH


                (TABLE 1-5) The plain Text: 0123456789ABCDEFH
                   0   0     0     0     0    0     0   1
                   0   0     1     0     0    0     1   1
                   0   1     0     0     0    1     0   1
                   0   1     1     0     0    1     1   1
                   1   0     0     0     1    0     0   1
                   1   0     1     0     1    0     1   1
                   1   1     0     0     1    1     0   1
                   1   1     1     0     1    1     1   1


           (TABLE 1-6) After Performing Initial Permutation (IP)
                  1     1     0     0     1      1   0      0
                  0     0     0     0     0      0   0      0
                  1     1     0     0     1      1   0      0
                  1     1     1     1     1      1   1      1
                  1     1     1     1     0      0   0      0
                  1     0     1     0     1      0   1      0
                  1     1     1     1     0      0   0      0
                  1     0     1     0     1      0   1      0


(TABLE 1-7) Expansion Permutation (E) for the 32 Right bits produced from the Initial
                                 permutation.
           0        1     1      1      1          0
           1        0     0      0      0          1
           0        1     0      1      0          1
           0        1     0      1      0          1
           0        1     1      1      1          0
           1        0     0      0      0          1
           0        1     0      1      0          1
           0        1     0      1      0          1
(TABLE 1-8)
                          (TABLE 1-4) XOR (TABLE 1-7)
                            Number of Row in the S Boxes
S1              1         0       1       1          1       1
S2              1         1       0       1          1       0
S3              1         0       0       1          0       1
S4              0         0       0       1          1       1
S5              1         1       0       0          1       0
S6              1         0       1       0          1       1
S7              1         0       0       1          0       1
S8              0         0       1       1          1       1
                          Number of Column in the S Box

         (TABLE 1-10) The result of substitution for the S-boxes
0        1     1       1       0       1        1        0
1        1     0       1       0       1        0        1
1        0     0       1       0       1        0        1
1        1     0       1       0       1        0        0

        (TABLE 1-11) The result of permutation P for the last table
1         1     1      0        0      1        1       1
0         0     0      1        0      0        0       1
1         0     1      1        0      0        1       1
0         0     1      1        1      0        1       1

                                  (TABLE 1-12)
                    R1= (TABLE 1-11) XOR (32 lift bits TABLE 1-6)
0           0           1     0       1      0          1    1
0           0           0     1       0      0          0    1
0           1           1     1       1      1          1    1
1           1           0     0       0      1          0    0

                        (TABLE 1-13) OUTPUT OF ROUND 1
        1           1     1    1     0   0   0   0
L1=R0




        1           0     1    0     1   0   1   0
        1           1     1    1     0   0   0   0
        1           0     1    0     1   0   1   0
        0           0     1    0     1   0   1   1
        0           0     0    1     0   0   0   1
R1




        0           1     1    1     1   1   1   1
        1           1     0    0     0   1   0   0
                         IN HEXADECIMAL:
                              L1       R1 :
                               F0AAF0AA2B117FC4H
2- For Des encryption:
(all inputs are in hexadecimal, outputs are in both hexadecimal and binary)
b- Write program that will accept 64bit plaintext and produces Lo and Ro.
(the 32 bit each, left and right output of the initial permutation)
The answer:

The program works as follows:
1-It takes 64bits plaintext in hexadecimal format, that means it accepts 16 digits and only 16digits.
2-If the input data contained spaces it will be removed.
3-you can enter hexadecimal numbers like A or a whether uppercase or lowercase no difference.
4-In case you entered less or larger than 16 Hexadecimal digits. An appropriate message will
appear asking the user to renter correct data.
5-In case you entered any character rather than any one of “0123456789abcdef”or
“0123456789ABCDEF”, for example like “Q” then an appropriate message will appear asking
the user to renter correct hexadecimal data.
6-The output of the program is:
   - The 8X8 binary matrix corresponding for the16 digits hexadecimal data entered.
   - The initial permutation IP 8X8 matrix.(i.e. Lo , Ro in Binary bits)
   - (Lo,Ro) in hexadecimal format.


The Program:

//Solution for problem 2-B

#include <stdio.h>
#include <ctype.h>
#include<iostream.h>
#include<iomanip.h>
#include <stdlib.h>
#include<math.h>
#include<string.h>
void arrange_input_plaintext_to_8_by_8_matrix(void);
void initial_permutation(void);
void conversion_to_hexadecimal_for_bin_permuted(void);
void getting_plaintext_cheking_and_converting_to_decimal(void);
int iptd[16],pt[8][8],ip[8][8];

 int main(void)
        {
               getting_plaintext_cheking_and_converting_to_decimal();
               arrange_input_plaintext_to_8_by_8_matrix();
                initial_permutation();
               return 0;
                }

//This function gets the input plaintext in hexadecimal,checks it and rectifing it from spaces
//moreover it converts it to decimal format
void getting_plaintext_cheking_and_converting_to_decimal(void)
{
int i,t;
char s[1000];
cout<<quot;PLease enter the 64 bits plaintext in Hexadecimal format:quot;<<endl;

xx:
gets(s);
for(i=0;i<strlen(s);i++)
s[i]=tolower(s[i]);

printf(quot;nquot;);
t=-1;
for(i=0;i<strlen(s);i++)
{
if(s[i]!=' ')
{
if((s[i]>=97)&&(s[i]<=102))
{iptd[++t]=s[i]-87;
continue;}
if((s[i]>=48)&&(s[i]<=57))
{iptd[++t]=s[i]-48;
continue;}

else
{printf(quot;nERROR: Not all input data are in Hexadecimal format.nquot;);
printf(quot;n Please renter 64bits plaintext in Hexadecimal format:nquot;);
goto xx;} }
if(s[i]==' ')
continue;

}
if(t!=15)
{cout<<quot;Error: Number of bits entered are not 64.quot;<<endl;
cout<<quot; Please Renter correct 16 hexadecimal numbers:quot;<<endl;
goto xx; }
}

//This function will take the input key text in hexadecimal and it will convert it to BINARY
//
//rearrange the data as 8*8 binary matrix
//THE FUNCTION WILL PRINT out THE DESIREED ARRANGED MATRIX which is ready for the next
stepquot;Permutationquot;

void arrange_input_plaintext_to_8_by_8_matrix(void)
{
        int i,j,n,x,b[4],cpt[16],onedpt[16][4],row,col,t;
        for(i=0;i<=15;i++)
cpt[i]=iptd[i];

for(j=0;j<16;j++)
{for(i=0;i<=3;i++)
{
x=cpt[j]%2;
if(x==0)
{
onedpt[j][3-i]=0;
cpt[j]/=2;}
else
{
onedpt[j][3-i]=1;
cpt[j]=(cpt[j]-1)/2;
}
}}

 row=0;col=0; t=0;
 printf(quot;nThe arranged 8X8 binary matrix corresponding for the entered plain text is:nquot;);
 for(i=0;i<8;i++)
{    printf(quot;nquot;);
for(j=0;j<8;j++)

{pt[i][j]=onedpt[row][col++];
++t;
if(t%4==0)
++row;
printf(quot;%dquot;,pt[i][j]);
if(col>=4)
col=0;}
}}


 /*THIS FUNCTION WILL PERFORM THE INITIAL PERMUTATION FOR THE MATRIX WHICH RESULTED FROM
THE
 AFOREMENTIONED FUNCTION*/
 //ALSO IT WILL PRINT THE PERMUTED RESULT IN BOTH BINARY AND HEXADECIMAL

void initial_permutation(void)
{
int i,j,t=-8,ipt[8][8];
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{if(i<=3)
ip[i][j]=pt[7-j][2*i+1];
if(i>=4)
ip[i][j]=pt[7-j][t]; }
t+=2;}
printf(quot;nThe initial permutaion 8X8 matrix is:nquot;);
 printf(quot;nLo:nquot;);
for(i=0;i<8;i++)
{printf(quot;nquot;);
for(j=0;j<8;j++)
 {if((i==4)&&(j==0))
 printf(quot;nRo:nquot;);
printf(quot; %d quot;,ip[i][j]);
  }
  }
conversion_to_hexadecimal_for_bin_permuted();
 }


//This Function converts the permuted values to hexadecimal and print them all out
void conversion_to_hexadecimal_for_bin_permuted(void)
{
int i,j,r=-1,odw[64],wdw[16][4],hex[64],sum;
                       printf(quot;nquot;);
for(i=0;i<8;i++)
for(j=0;j<8;j++)
odw[++r]=ip[i][j];
r=-1;
printf(quot;nquot;);
for(i=0;i<16;i++)
 for(j=0;j<4;j++)
wdw[i][j]=odw[++r];

for(i=0;i<16;i++)
{
sum=0;
for(j=0;j<4;j++)
sum+=(pow(2,3-j))*wdw[i][j];
hex[i]=sum;}
cout<<quot;In hexadecimal:quot;<<endl;
cout<<quot; Lo quot;<<quot; Ro quot;<<endl;
for(i=0;i<16;i++)
{ if(i==8)
 cout<<' ';
printf(quot;%xquot;,hex[i]);
}
           }

Contenu connexe

Similaire à Microsoft Word Hw#2

Bài tập-des
Bài tập-desBài tập-des
Bài tập-desHuynh MVT
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colorssynesthesiapatterns
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colorssynesthesiapatterns
 
Binary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwBinary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwJoji Thompson
 
Combinational logic 2
Combinational logic 2Combinational logic 2
Combinational logic 2Heman Pathak
 
Mux decod pld2_vs2
Mux decod pld2_vs2Mux decod pld2_vs2
Mux decod pld2_vs2WanNurdiana
 
Second digital revolution
Second digital revolutionSecond digital revolution
Second digital revolutionCharlie Makin
 
Gateeee2012q20logicdesign
Gateeee2012q20logicdesignGateeee2012q20logicdesign
Gateeee2012q20logicdesignMickey Boz
 
Gateece2012q19logicdesign
Gateece2012q19logicdesignGateece2012q19logicdesign
Gateece2012q19logicdesignetenneti
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colorssynesthesiapatterns
 
Tutorial 0 mth 3201
Tutorial 0 mth 3201Tutorial 0 mth 3201
Tutorial 0 mth 3201Drradz Maths
 
Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphschidabdu
 
Derby presentation
Derby presentationDerby presentation
Derby presentationScott Turner
 
Andrew Goldberg. An Efficient Point-to–Point Shortest Path Algorithm
Andrew Goldberg. An Efficient Point-to–Point  Shortest Path AlgorithmAndrew Goldberg. An Efficient Point-to–Point  Shortest Path Algorithm
Andrew Goldberg. An Efficient Point-to–Point Shortest Path AlgorithmComputer Science Club
 

Similaire à Microsoft Word Hw#2 (20)

16%20 lecture
16%20 lecture16%20 lecture
16%20 lecture
 
Bài tập-des
Bài tập-desBài tập-des
Bài tập-des
 
Informatico
InformaticoInformatico
Informatico
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colors
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colors
 
Binary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwBinary Mathematics Classwork and Hw
Binary Mathematics Classwork and Hw
 
Binary addition
Binary additionBinary addition
Binary addition
 
Combinational logic 2
Combinational logic 2Combinational logic 2
Combinational logic 2
 
Crc
CrcCrc
Crc
 
Mux decod pld2_vs2
Mux decod pld2_vs2Mux decod pld2_vs2
Mux decod pld2_vs2
 
Binary operations
 Binary operations Binary operations
Binary operations
 
Second digital revolution
Second digital revolutionSecond digital revolution
Second digital revolution
 
Gateeee2012q20logicdesign
Gateeee2012q20logicdesignGateeee2012q20logicdesign
Gateeee2012q20logicdesign
 
Gateece2012q19logicdesign
Gateece2012q19logicdesignGateece2012q19logicdesign
Gateece2012q19logicdesign
 
Synesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and ColorsSynesthetic Associational Patterns between Letters and Colors
Synesthetic Associational Patterns between Letters and Colors
 
Tutorial 0 mth 3201
Tutorial 0 mth 3201Tutorial 0 mth 3201
Tutorial 0 mth 3201
 
Sienna 11 graphs
Sienna 11 graphsSienna 11 graphs
Sienna 11 graphs
 
Derby presentation
Derby presentationDerby presentation
Derby presentation
 
Andrew Goldberg. An Efficient Point-to–Point Shortest Path Algorithm
Andrew Goldberg. An Efficient Point-to–Point  Shortest Path AlgorithmAndrew Goldberg. An Efficient Point-to–Point  Shortest Path Algorithm
Andrew Goldberg. An Efficient Point-to–Point Shortest Path Algorithm
 
Gerbang logikanya
Gerbang  logikanyaGerbang  logikanya
Gerbang logikanya
 

Plus de kkkseld

Microsoft Word The Project, Islam And Science
Microsoft Word   The Project, Islam And ScienceMicrosoft Word   The Project, Islam And Science
Microsoft Word The Project, Islam And Sciencekkkseld
 
Speech To Sign Language Interpreter System
Speech To Sign Language Interpreter SystemSpeech To Sign Language Interpreter System
Speech To Sign Language Interpreter Systemkkkseld
 
Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewallskkkseld
 
Mobile Multi Media Applications
Mobile Multi Media ApplicationsMobile Multi Media Applications
Mobile Multi Media Applicationskkkseld
 
Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewallskkkseld
 
Kerie2006 Poster Template 01
Kerie2006 Poster Template 01Kerie2006 Poster Template 01
Kerie2006 Poster Template 01kkkseld
 

Plus de kkkseld (9)

Asr
AsrAsr
Asr
 
Microsoft Word The Project, Islam And Science
Microsoft Word   The Project, Islam And ScienceMicrosoft Word   The Project, Islam And Science
Microsoft Word The Project, Islam And Science
 
Speech To Sign Language Interpreter System
Speech To Sign Language Interpreter SystemSpeech To Sign Language Interpreter System
Speech To Sign Language Interpreter System
 
Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewalls
 
Sslis
SslisSslis
Sslis
 
Mobile Multi Media Applications
Mobile Multi Media ApplicationsMobile Multi Media Applications
Mobile Multi Media Applications
 
Presentation, Firewalls
Presentation, FirewallsPresentation, Firewalls
Presentation, Firewalls
 
Kerie2006 Poster Template 01
Kerie2006 Poster Template 01Kerie2006 Poster Template 01
Kerie2006 Poster Template 01
 
Asr
AsrAsr
Asr
 

Dernier

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Dernier (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Microsoft Word Hw#2

  • 1. 1- Given an input key ABCDEF0123456789H, and the plaintext 0123456789ABCDEFH, perform a one round encryption using DES. Show intermediate results after each function. Solution: Calculations for the first subkey k1: - Input key: ABCDEF0123456789H (TABLE 1-1) Input key 64 bits 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 (TABLE 1-2) Permuted Choice one (PC-1) [56 bits] 1 0 0 0 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 0 0 0 (TABLE 1-3) Left Shift by 1 (for round 1) for each 32 bits [C0 D0] separately 0 0 0 0 1 1 1 0 1 1 0 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 0 0 0 0
  • 2. (TABLE 1-4)Permuted Choice Two (Pc-2) [48 bits Subkey K1] 1 1 0 0 0 1 0 1 0 1 1 1 1 1 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 0 0 0 1 0 1 0 1 1 0 0 0 0 0 1 1 0 1 0 Converting LAST table to Hexadecimal yields: C57C12B0AC1AH (TABLE 1-5) The plain Text: 0123456789ABCDEFH 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 (TABLE 1-6) After Performing Initial Permutation (IP) 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 (TABLE 1-7) Expansion Permutation (E) for the 32 Right bits produced from the Initial permutation. 0 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1
  • 3. (TABLE 1-8) (TABLE 1-4) XOR (TABLE 1-7) Number of Row in the S Boxes S1 1 0 1 1 1 1 S2 1 1 0 1 1 0 S3 1 0 0 1 0 1 S4 0 0 0 1 1 1 S5 1 1 0 0 1 0 S6 1 0 1 0 1 1 S7 1 0 0 1 0 1 S8 0 0 1 1 1 1 Number of Column in the S Box (TABLE 1-10) The result of substitution for the S-boxes 0 1 1 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1 0 1 0 0 (TABLE 1-11) The result of permutation P for the last table 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 (TABLE 1-12) R1= (TABLE 1-11) XOR (32 lift bits TABLE 1-6) 0 0 1 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 (TABLE 1-13) OUTPUT OF ROUND 1 1 1 1 1 0 0 0 0 L1=R0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 0 0 1 0 0 0 1 R1 0 1 1 1 1 1 1 1 1 1 0 0 0 1 0 0 IN HEXADECIMAL: L1 R1 : F0AAF0AA2B117FC4H
  • 4. 2- For Des encryption: (all inputs are in hexadecimal, outputs are in both hexadecimal and binary) b- Write program that will accept 64bit plaintext and produces Lo and Ro. (the 32 bit each, left and right output of the initial permutation) The answer: The program works as follows: 1-It takes 64bits plaintext in hexadecimal format, that means it accepts 16 digits and only 16digits. 2-If the input data contained spaces it will be removed. 3-you can enter hexadecimal numbers like A or a whether uppercase or lowercase no difference. 4-In case you entered less or larger than 16 Hexadecimal digits. An appropriate message will appear asking the user to renter correct data. 5-In case you entered any character rather than any one of “0123456789abcdef”or “0123456789ABCDEF”, for example like “Q” then an appropriate message will appear asking the user to renter correct hexadecimal data. 6-The output of the program is: - The 8X8 binary matrix corresponding for the16 digits hexadecimal data entered. - The initial permutation IP 8X8 matrix.(i.e. Lo , Ro in Binary bits) - (Lo,Ro) in hexadecimal format. The Program: //Solution for problem 2-B #include <stdio.h> #include <ctype.h> #include<iostream.h> #include<iomanip.h> #include <stdlib.h> #include<math.h> #include<string.h> void arrange_input_plaintext_to_8_by_8_matrix(void); void initial_permutation(void); void conversion_to_hexadecimal_for_bin_permuted(void); void getting_plaintext_cheking_and_converting_to_decimal(void); int iptd[16],pt[8][8],ip[8][8]; int main(void) { getting_plaintext_cheking_and_converting_to_decimal(); arrange_input_plaintext_to_8_by_8_matrix(); initial_permutation(); return 0; } //This function gets the input plaintext in hexadecimal,checks it and rectifing it from spaces //moreover it converts it to decimal format void getting_plaintext_cheking_and_converting_to_decimal(void) { int i,t;
  • 5. char s[1000]; cout<<quot;PLease enter the 64 bits plaintext in Hexadecimal format:quot;<<endl; xx: gets(s); for(i=0;i<strlen(s);i++) s[i]=tolower(s[i]); printf(quot;nquot;); t=-1; for(i=0;i<strlen(s);i++) { if(s[i]!=' ') { if((s[i]>=97)&&(s[i]<=102)) {iptd[++t]=s[i]-87; continue;} if((s[i]>=48)&&(s[i]<=57)) {iptd[++t]=s[i]-48; continue;} else {printf(quot;nERROR: Not all input data are in Hexadecimal format.nquot;); printf(quot;n Please renter 64bits plaintext in Hexadecimal format:nquot;); goto xx;} } if(s[i]==' ') continue; } if(t!=15) {cout<<quot;Error: Number of bits entered are not 64.quot;<<endl; cout<<quot; Please Renter correct 16 hexadecimal numbers:quot;<<endl; goto xx; } } //This function will take the input key text in hexadecimal and it will convert it to BINARY // //rearrange the data as 8*8 binary matrix //THE FUNCTION WILL PRINT out THE DESIREED ARRANGED MATRIX which is ready for the next stepquot;Permutationquot; void arrange_input_plaintext_to_8_by_8_matrix(void) { int i,j,n,x,b[4],cpt[16],onedpt[16][4],row,col,t; for(i=0;i<=15;i++) cpt[i]=iptd[i]; for(j=0;j<16;j++) {for(i=0;i<=3;i++) { x=cpt[j]%2; if(x==0) { onedpt[j][3-i]=0; cpt[j]/=2;}
  • 6. else { onedpt[j][3-i]=1; cpt[j]=(cpt[j]-1)/2; } }} row=0;col=0; t=0; printf(quot;nThe arranged 8X8 binary matrix corresponding for the entered plain text is:nquot;); for(i=0;i<8;i++) { printf(quot;nquot;); for(j=0;j<8;j++) {pt[i][j]=onedpt[row][col++]; ++t; if(t%4==0) ++row; printf(quot;%dquot;,pt[i][j]); if(col>=4) col=0;} }} /*THIS FUNCTION WILL PERFORM THE INITIAL PERMUTATION FOR THE MATRIX WHICH RESULTED FROM THE AFOREMENTIONED FUNCTION*/ //ALSO IT WILL PRINT THE PERMUTED RESULT IN BOTH BINARY AND HEXADECIMAL void initial_permutation(void) { int i,j,t=-8,ipt[8][8]; for(i=0;i<8;i++) { for(j=0;j<8;j++) {if(i<=3) ip[i][j]=pt[7-j][2*i+1]; if(i>=4) ip[i][j]=pt[7-j][t]; } t+=2;} printf(quot;nThe initial permutaion 8X8 matrix is:nquot;); printf(quot;nLo:nquot;); for(i=0;i<8;i++) {printf(quot;nquot;); for(j=0;j<8;j++) {if((i==4)&&(j==0)) printf(quot;nRo:nquot;); printf(quot; %d quot;,ip[i][j]); } } conversion_to_hexadecimal_for_bin_permuted(); } //This Function converts the permuted values to hexadecimal and print them all out
  • 7. void conversion_to_hexadecimal_for_bin_permuted(void) { int i,j,r=-1,odw[64],wdw[16][4],hex[64],sum; printf(quot;nquot;); for(i=0;i<8;i++) for(j=0;j<8;j++) odw[++r]=ip[i][j]; r=-1; printf(quot;nquot;); for(i=0;i<16;i++) for(j=0;j<4;j++) wdw[i][j]=odw[++r]; for(i=0;i<16;i++) { sum=0; for(j=0;j<4;j++) sum+=(pow(2,3-j))*wdw[i][j]; hex[i]=sum;} cout<<quot;In hexadecimal:quot;<<endl; cout<<quot; Lo quot;<<quot; Ro quot;<<endl; for(i=0;i<16;i++) { if(i==8) cout<<' '; printf(quot;%xquot;,hex[i]); } }