The following question is for C programming.
There is a function that has the header char * decodeSubstitution(char * lcEncodingKey, char * src, char *dest)
What it ultimately is supposed to do is take an encoded array of characters (src), decode it and put it into dest, and return the decoded array of characters. The first step, however, is what I need help with. The first step is to create the decoding key called lcDecodingKey using the encoding key was was passed as an argument. The encoding key passed in this case is an array of characters is called lcEncodingKey and is the array of characters "qwertyuiopasdfghjklzxcvbnm". We ultimately want the decoding key to be "abcdefghijklmnopqrstuvwxyz". The result of this is a 'q' would become an 'a', a 'w' would become a 'b', an 'e' would become a 'c' etc. We had originally encoded the phrase "Ciphers are fun" to "Eohitkl qkt yxf", and now in this function we want to decode "Eohitkl qkt yxf" back to "Ciphers are fun". I just need help with the first part of creating the decoding key using the encoding key.
C CODE:
#include <stdio.h>
#include<string.h>
char * decodeSubstitution(char * lcEncodingKey, char * src, char
*dest){
char lcDecodingKey[26];//initialize the decoding key of 26
character as there are 26 alphabets in total
// we would iterate 26 times and each time we take the character
from the encoding key and
//calculate it's index in by subtracting from 'a'
//The index which is calculated is used to decode
//e.g index of q will be 17 we will go at 17th index in decoding
key and put character 'a' in it as it represents a
//this way we will iterate through lcEncodingKey and calculate
index of all and then put the character one by one in it
for(int i=0;i<26;++i)
{
char ch=(char)('a'+i);
lcDecodingKey[lcEncodingKey[i]-'a']=ch; //put the character in
decoding key
}
int l =strlen(src);
//decode function
for(int i=0;i<l;++i)
{
if(src[i]==' ')
dest[i]=' '; //if space then input space in dest
else
{
if(src[i]>='a'&&src[i]<='z')
dest[i]=lcDecodingKey[src[i]-'a'];
else
dest[i]='A'+lcDecodingKey[src[i]-'A']-'a'; // if the string has
capital letter than index will be calculate by subtracting it
//from 'A'
//then to put capital letter to its place we need to add 'A' and
subtract 'a' as decoding key has characters in lower case
//only
}
}
printf("%s ",dest);
return dest;
}
int main()
{
char * lcEncodingKey="qwertyuiopasdfghjklzxcvbnm";
char *src="Eohitkl qkt yxf";
char dest[26];
char *d;
d=decodeSubstitution(lcEncodingKey,src,dest);
return 0;
}
DECODING KEY GENERATED IS :
kxvmcnophqrszyijadlegwbuft
The following question is for C programming. There is a function that has the header char...
In C++ Having heard you have gotten really good at programming, your friend has come to ask for your help with a simple task. She would like you to implement a program to encrypt the messages she exchanges with her friends. The idea is very simple. Every letter of the alphabet will be substituted with some other letter according to a given key pattern like the one below. "abcdefghijklmnopqrstuvwxyz" "doxrhvauspntbcmqlfgwijezky" // key pattern For example, every 'a' will become a...
Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program is required that allows a user to encode text using any of three possible ciphers. The three ciphers you are to offer are: Caesar, Playfair and Columnar Transposition. • The program needs to loop, repeating to ask the user if they wish to play with Caesar, Playfair or Columnar Transposition until the user wishes to stop the program. •For encoding, the program needs to...
Q16-Decoder (0.5 points) Write a code block to decode strings from secret encodings back to readable messages. To do so: Initialize a variable called decoded as an empty string . Use a for loop to loop across all characters of a presumed string variable called encoded Inside the loop, convert the character to another character o Get the unicode code point for the character (using ord o Subtract the value of key to that code point (which should be an...
Do this using the C language. show me the code being executed and also copy and paste the code so i can try it out for myseld Instructions A cipher is mirrored algorithm that allow phrases or messages to be obfuscated (ie. "scrambled"). Ciphers were an early form of security used to send hidden messages from one party to another. The most famous and classic example of a cipher is the Caesar Cipher. This cypher worked by shifting each letter...
cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...
WE ARE USING PYTHON TO COMPLETE THIS ASSIGNMENT :) THANK YOU! In this programming assignment, you will write functions to encrypt and decrypt messages using simple substitution ciphers. Your solution MUST include: a function called encode that takes two parameters: key, a 26-character long string that identifies the ciphertext mapping for each letter of the alphabet, in order; plaintext, a string of unspecified length that represents the message to be encoded. encode will return a string representing the ciphertext. a...
C code only! Complete this function so that the function str2int convert the char array s into its equivalent integer value. The char array has only digit characters of{0, 1, .., 9}and ’\0’.And the first element is not 0, which means, the integer string in the char array is of base 10. For example, if we pass chars[] = ”123” intostr2int, then it should return 123.Close the braces when you are done int str2int(char s[]){
C++ Programming Question: This programming assignment is intended to demonstrate your knowledge of the following: ▪ Writing a while loop ▪ Write functions and calling functions Text Processing [50 points] We would like to demonstrate our ability to control strings and use methods. There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It...
Write in C Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...