Alice and Bob want to exchange the n- digits message on the internet, but they want to ensure the security. They went to a cyber security specialist Edwin for the solution. Edwin listened to the requirement of the clients and proposed a scheme for cryptography, which is mentioned in following points 1. The algorithm would reverse the message 2. After reverting the message, it would determine an alphabetic character against the digit. For example, for 0 it would be A, for 1 it would be B, for 2 it would be C, for Z it would be 25. Write a code in C for the above cryptographic algorithm using loops in C for Edwin. The samples are like: Input String Cypher Text 1546 GEFB 7777 HHHH 5555 FFFF 1234 EDCB

Questions & AnswersCategory: Programming LanguageAlice and Bob want to exchange the n- digits message on the internet, but they want to ensure the security. They went to a cyber security specialist Edwin for the solution. Edwin listened to the requirement of the clients and proposed a scheme for cryptography, which is mentioned in following points 1. The algorithm would reverse the message 2. After reverting the message, it would determine an alphabetic character against the digit. For example, for 0 it would be A, for 1 it would be B, for 2 it would be C, for Z it would be 25. Write a code in C for the above cryptographic algorithm using loops in C for Edwin. The samples are like: Input String Cypher Text 1546 GEFB 7777 HHHH 5555 FFFF 1234 EDCB
ashok asked 2 years ago

Alice and Bob want to exchange the n- digits message on the internet, but they want to ensure the security.
They went to a cyber security specialist Edwin for the solution. Edwin listened to the requirement of the
clients and proposed a scheme for cryptography, which is mentioned in following points
1. The algorithm would reverse the message
2. After reverting the message, it would determine an alphabetic character against the digit. For
example, for 0 it would be A, for 1 it would be B, for 2 it would be C, for Z it would be 25.
Write a code in C for the above cryptographic algorithm using loops in C for Edwin.
The samples are like:
Input String – Cypher Text
1546                GEFB
7777                HHHH
5555                FFFF
1234                EDCB

1 Answers
Lokesh Kumar Staff answered 2 years ago
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main(){

    char input_text[20];
    int j = 0;
    char alphabets[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    printf("Enter your message: ");
    scanf("%s", &input_text);
    strrev(input_text);
    //printf("%d", strlen(input_text));

    for (int i=0; i<strlen(input_text); i++){
        j = 0;
        while(alphabets[j]!=input_text[i]){
            //printf("%c", alphabets[j]);
            j++;
        }
        printf("%d", j);
    }
    return 0;
}