Cipher, text wrapping

I am working on a piece of homework based on a cipher, I have the key and the message in separate arrays. I want to create a third array that will contain the key wrapped around to fit the size of the message, like so:

message
keykeyk

Have been struggling with this one for a while, any help will be greatly appreciated!!

Solutions

something like wrappedKey[i] = key[i % keyLength] where 0 <= i < messageLength – Drew McGowen

Tags: C / Text / Word Wrap

Similar questions

How to cipher a text in C?
I am working on a problem and I am a bit stuck so I thought to ask for your help. I want to make a program with the following capabilities. The user will give a 4 digit cipher key and a text. Then the text will be converted in cipher using the following method. Let's say that the text input was 'ABC' and the key was 123. Then, using the ASCII table...
Why the length of cipher text generated by php via mcrypt_encrypt() is different from the one generated by C via openssl encryption library
I tried this code from openssl wiki which generate a cipher text via aes-256 algorithm. The length of input plain text is 512 bytes. The length of output, however, is difference. PHP generate an output which length is 512 bytes, whereas the C generate a 528 bytes long cipher text. why there exist such a difference and how could I use an aes-256 alg...
Caesar cipher printing out numbers instead of decrypted Text? in C
So I have this caesar cipher program, however when I run it it only prints out numbers instead of the decrypted text. Anyone know what I am missing? I believe there might be something wrong in the bool solved function.
Cipher text in C,How to repeat key characters
Explanation The ciphertext is generated from the plaintext by “adding” corresponding characters of the plaintext and the key together. If the plaintext is shorter than the key, only some of the key will be used. Similarly, if the plaintext is shorter than the key, the key will be used multiple times. For example, to encode the plaintext “HELLO” wit...
Caesar cipher and reverse text program
I'm trying to make a function that gets a string and a number and if the number is bigger the '0' so it will make the caesar cipher with the string and the number that the user entered. for example -> 'stack' and the number is '3' -> 'uvdfn'. if the number is '0' so it will reverse the string. for example - 'stack' -> 'kcats' I don't know what is t...
Encrypt text using Caesar's Cipher
I was writing this C program which takes in a command line argument , and then encrypts a text later entered by the user. We enter a number through command line which is used in encryption. For eg , if we eter a number 1 from command line and then the user wants to encrypt say "aaaa" , the encrypted text will be "bbbb" , just that each has shifted ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.