Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • C programming encrypting a message

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 551
    Answer it

    Hey guys, i am a C programming beginner and looking for help urgently.

    I need to Write a function to encrypt a message given as a string input using the given encryption key. The function should output the encrypted message as a string to encryptedMessage in the argument list. The function prototype must be as follows: void encryptMessage(char *encryptedMessage, char *message, char *encryptionKey);

    The function must take the encryption key and convert each of its characters, which represent hexadecimal digits, to their equivalent decimal values as integers. The message must then be encrypted by adding the first of these integer values to the ASCII value of the first character in the message, and the second of the integer values to the second character in the message, and so on, and start again with the first integer value after every 16. This will be necessary if the message is longer than the encryption key, which will usually be the case.

    I already wrote a function to convert hexadecimal to dec which works perfectly fine: here is my code so far but my loop never seems to end :/

    void encryptMessage(char encryptedMessage, char *message, char *encryptionKey) { int *arr = malloc(sizeof(int)getStringLength(encryptionKey));

    int i = 0;
    while(i < getStringLength(encryptionKey)){
        arr[i] = hexDigit2Dec(encryptionKey[i]);
        message[i] = message[i] + (char)arr[i];
        i++;
    }
    

    }

    Can someone please help me out!Thanks

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: