Answered step by step
Verified Expert Solution
Link Copied!

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 ModuloAdd(const int l, const int r); Accepts two integers that contains 4 bit numbers each. It adds the two numbers together and returns the remainder of division by 16( modulo 16).
int ModuloMul(const int l, const int r); Accepts two integers that contain 4 bit numbers each. If either number is zero it uses 16 for them instead. Multiplies both numbers and returns the remainder of division by 17(modulo 17).
int ModuloXor(const int l, const int r); Accepts two integers that contain 4 bit numbers each. Returns the result of XOR of both numbers.
int CircularShiftLeft(const int w, int a);. Accepts as input a 32 bit integer and a shift amount ( second parameter ). It looks as the shift amount, saves those number of bits from the 32 word passed in, shiftw the number left by that value and tacks on the front digits on the back.
int GetNibble(const int w, int nibble); Accepts as input a word and the nibble number. The word has 8 four bit nibbles in it. This routine grabs one of the 8 nibbles (1-8) and returns those four bits right justified as an integer. Let us saythat I passed in
11001010000010000010010000110001 as the word and the number 3 as the nibble. The routine would return 0000.
int ConvertChartoHex(const char x); Accepts a character in the range of 0-9 and a-f or A-F which represents an hexidecimal character and returns the integer version of it.'0' returns integer 0,'1' returns an integer 1,'a' returns an integer 10, etc.
char ConvertInttoChar(const int x); Does the opposite of the previous routine. It accepts an integer in the range of 0-15 and returns as a character the hexadecimal value. Zero (0) return '0', one (1) returns '1', ten (10) returns 'a', etc.
void GenerateKeySchedule(const string & s); Fills out the keyschedule two dimensional array in accordance with the IDEA algorithm. Takes in the string s which represents the hexadecimal 32 bit encryption key. Also stores the keycode in the private data item.
string & GenerateSecretCode(const 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 Round(const 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 Round5(); // Performs the first four steps of the basic round as the last round in the encryption. When it is done, X1, X2, X3, and X4 will contain the encrypted code.
//********************************************************************
// Created by David Gaitros on 11/22/23.*
// Object Oriented interface to the IDEA simplified algorithm. *
//********************************************************************
#ifndef IDEA_H
#define IDEA_H
#include
#include
#include
#include
using namespace std;
//**************************************************************
//* Non IDEA class functions. *
//**************************************************************
int ModuloAdd(const int l, const int r);
int ModuloMul(const int l, const int r);
int ModuloXor(const int l, const int r);
int CircularShiftLeft(const int w, int a);
int GetNibble(const int w, int nibble);
int ConvertChartoHex(const char x);
char ConvertInttoChar(const int x);
class IDEA {
public:
void GenerateKeySchedule(const string & s);
string & GenerateSecretCode(const string & s);
void PrintTable();
void PrintSecretCode();
void PrintASCIISecretCode();
private:
int key; //32 bit key converted from a string to an integer
int keyschedule[6][7]; // Key Table, 0 indexes not used [1-5][1-6]
void Round(const int rnum); // Generic Round , rnum can be 1,2,3 or 4
void Round5(); // Round 5
vector secretcode; // One hex digit for each word, Make it easy
int X1,X2,X3,X4; // X1 through X4 values
int step1,// Results of step1 in each round
step2,// Results of step2 in each round
step3,// Results of step3 in each round
step4,// Results of step4 in each round
step5,// Results of step5 in each round
step6,// Results of step6 in each round
step7,// Results of step7 in each round
step8,// Results of step8 in each round
step9,// Results of step9 in each round
step10; // Results of step10 in each round
string codeword; // The answer
string keycode; // Origial Key
};
#endif //IDEA_H

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

4. What are alternative methods for building information systems?

Answered: 1 week ago