Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write in C + + Please use all functions. int ModuloAdd ( const int l , const int r ) ; Accepts two integers that
Write in C Please use all functions.
int ModuloAddconst int l const int r; Accepts two integers that contains bit numbers each. It adds the two numbers together and returns the remainder of division by modulo
int ModuloMulconst int l const int r; Accepts two integers that contain bit numbers each. If either number is zero it uses for them instead. Multiplies both numbers and returns the remainder of division by modulo
int ModuloXorconst int l const int r; Accepts two integers that contain bit numbers each. Returns the result of XOR of both numbers.
int CircularShiftLeftconst int w int a; Accepts as input a bit integer and a shift amount second parameter It looks as the shift amount, saves those number of bits from the word passed in shiftw the number left by that value and tacks on the front digits on the back.
int GetNibbleconst int w int nibble; Accepts as input a word and the nibble number. The word has four bit nibbles in it This routine grabs one of the nibbles and returns those four bits right justified as an integer. Let us saythat I passed in
as the word and the number as the nibble. The routine would return
int ConvertChartoHexconst char x; Accepts a character in the range of and af or AF which represents an hexidecimal character and returns the integer version of it returns integer returns an integer a returns an integer etc.
char ConvertInttoCharconst int x; Does the opposite of the previous routine. It accepts an integer in the range of and returns as a character the hexadecimal value. Zero return one returns ten returns a etc.
void GenerateKeyScheduleconst string & s; Fills out the keyschedule two dimensional array in accordance with the IDEA algorithm. Takes in the string s which represents the hexadecimal bit encryption key. Also stores the keycode in the private data item.
string & GenerateSecretCodeconst string & s; Takes in the string s which is a basic ASCII character string and generates the encrypted code using the IDEA Algorithm. Remember that the algorithm works on a pair of characaters.
void PrintSecretCode; Outputs the Code Key and the encrypted message to standard output. No messages printed out...just the code key on one line and the encrypted message in the form of Hexadecimal characters to standard output.
void Roundconst int rnum; Performs a round of the encryption. The X values and KeySchedule are available through the private data items. The round number is passed in as rnum so that you can determine which part of the KeySchedule to use.
void Round; Performs the first four steps of the basic round as the last round in the encryption. When it is done, X X X and X will contain the encrypted code.
Created by David Gaitros on
Object Oriented interface to the IDEA simplified algorithm.
#ifndef IDEAH
#define IDEAH
#include
#include
#include
#include
using namespace std;
Non IDEA class functions.
int ModuloAddconst int l const int r;
int ModuloMulconst int l const int r;
int ModuloXorconst int l const int r;
int CircularShiftLeftconst int w int a;
int GetNibbleconst int w int nibble;
int ConvertChartoHexconst char x;
char ConvertInttoCharconst int x;
class IDEA
public:
void GenerateKeyScheduleconst string & s;
string & GenerateSecretCodeconst string & s;
void PrintTable;
void PrintSecretCode;
void PrintASCIISecretCode;
private:
int key; bit key converted from a string to an integer
int keyschedule; Key Table, indexes not used
void Roundconst int rnum; Generic Round rnum can be or
void Round; Round
vector secretcode; One hex digit for each word, Make it easy
int XXXX; X through X values
int step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step Results of step in each round
step; Results of step in each round
string codeword; The answer
string keycode; Origial Key
;
#endif IDEAH
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started