2 votes
Accepted

Pset2 - Caesar (less comfortable) wraparound problems

I got it working, maybe this will help somebody else. I'll detail my reasoning, so please correct me if anything is wrong. In my code above I had written: (plain[i]-65) + k) % 26); as a way of ...
user avatar
  • 33
2 votes

How to wrap around the jth element in vigenere cipher efficiently?

I am among those people who suggest you to use 2 loop variables, actually its 1. Use a variable (say i) to iterate over each element of the input string and maintain another variable (say j) to hover ...
user avatar
  • 3,326
1 vote
Accepted

Pset2 - Vigenere Cipher Shifting An Extra 13 Letters To The Right

In this code, you see how you subtracted 'a' from the plaintext? int f = plaintext[c] - 'a'; plaintext[c] = ((f + input[e]) % 26) + 'a'; input[e] still contains an ASCII ...
user avatar
  • 64.2k
1 vote
Accepted

PSET2, Vigenere: Wraparound is not working properly

if (j % (strlen(argv[1]) - 1) == 0) Why are you subtracting 1? That deals with correcting the reset to 0. However, there is a serious logic problem in the code. Simply put, nested for loops simply ...
user avatar
  • 64.2k
1 vote
Accepted

Unable to make string wrap around in PSET2

After the first pass through the key, every char in the key has been converted to numbers between 0 and 25 inclusive. Starting on the second pass through, the else clauses are executing, moving the ...
user avatar
  • 64.2k
1 vote

Don't know where to start for key wraparound in vigenere pset2

When I did this (yesterday) I obtained the string length of the key, then obtained the modulus of the length of the key. j % lengthOfKeyVariable then I incremented j, as long as you don't reset J ...
user avatar
  • 111
1 vote
Accepted

Pset2 Caesar wrap around result is inexplicably incorrect

It probably works fine with 1, but the rest is an accurate description of what is happening. Your problem is here: char ciphertext = 'a' + ((plaintext[i] + key) % 26); Try plugging the actual ...
user avatar
  • 64.2k
1 vote

How to wrap around the jth element in vigenere cipher efficiently?

another way to do it j++; j = j % v; where j is the jth char of key and v is strlen of key. when placed at the end of your shift functions within your if statement, j will increment only when you've ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible