c,image-segmentation,memory-segmentation,vigenere
Two problems: 1) you're not terminating your output string - change: *output_key = malloc(strlen(input_string) * sizeof(char)); to: *output_key = malloc(strlen(input_string) + 1); and make sure you add a '\0' terminator, e.g. in parseAlphaKey add a line: (*output_key)[n] = '\0'; after the loop. 2) you're getting bitten by operator precedence -...
python,python-2.7,encryption,transpose,vigenere
The columnar transposition does take a word as key, not a number. If "exam" is the key, then you write out the message from left to write in rows of four and read off the cipher text from top to bottom starting with column 3, then column 1, then column...
int allstralpha(); int allstralpha(string s) { ... } Your function definition and declaration don't match. You should declare int allstralpha(string s); In first line of main: int main(int argc, string argv[]) { string keyw = argv[1]; ... } First you should check if (argc > 1) before accessing argv[1] For...
The only difference between your code and your comments is you're using % 94 when the range 32 to 126 includes 95 characters. Changing your corresponding statement to use modulo 95, and breaking it up a bit: int caesar = _key.charAt(i % _key.length()) - 32; int sum = c -...
You can use another loop variable an make the index of the key 0 every time it reaches its length. I have used variable j in this case. Try this code: #include<stdio.h> #include<string.h> int main() { char str[100],k[50],str1[100]; int i,n; gets(str);// Input plain text. gets(str1);//Input key. int lenk=strlen(str1),j; //calculate length...
python,python-3.x,encryption,vigenere
You call join on the list to join the contents, not str(list), you are casting the list itself to a str and calling join on that, not the actual list. You need to map each int to a str in your case. "".join(map(str,list_out)) Which is equivalent to "".join([str(x) for x...
python,python-3.x,encryption,indices,vigenere
for i in range(len(text)): print(alphabet.index(text.lower()[i])) just add lower() and it will work...
The first for loop has a problem. The condition is checking for i > keylen when it should be checking for i < keylen. Also when computing the next output value, the steps should be (p[i]-65) results in a number between 0 and 25 adding (key[i % keylen]) results in...
First, you need to change: key[i] + ord(key[i])-97 To: key[i] = ord(key[i])-97 It seems that is a mistyping. Second, the ord(...) function returns an int. You want to convert it back to a char using chr(...): key[i] = chr(ord(key[i])-97) Finally, in Python, strings are immutable. This means you can't change...
Background The code uses the ASCII value of the letters. The letters A-Z are ASCII values 65-90. The idea is to add the two letters together, but wrap around if the values goes above 90 (known as modular arithmetic). So 91 should actually be 65 (i.e. Z + 1 =...
Your problem is that the key itself is made of upper and lower case chars. SO it works well for BaR as this word has the same case as the key BaZ, but for Foo the last o is lower case and the key is upper so the computation LtrNum...
The problem is in this line in the encrypt1 function: int keyIndex = alphabet.get(passwordPos++ % password.length()); Here you're trying to look up a key in the password, but you're actually getting it from the alphabet. What you want is to find the relevant character from the password (looping around when...