vigenere

Vigenere Cipher

微笑、不失礼 提交于 2020-01-08 04:17:46
问题 I am trying to make Vigenere Cipher in C. https://www.youtube.com/watch?v=9zASwVoshiM this is info about Vigenere Cipher. My code works doesnt work for certain cases like encrypts "world, say hello!" as "xoqmd, rby gflkp!" using "baz" as keyword instead it encrypts it as xomd, szz fl. Another example is: encrypts "BaRFoo" as "CaQGon" using "BaZ" as keyword but instead it encrypts it as CakGo. My code is given below please help me out: #include<stdio.h> #include<cs50.h> #include<ctype.h>

Vigenere cipher 'string index out of range' for decryption

拥有回忆 提交于 2020-01-07 01:49:27
问题 my Vigenere cipher works perfectly for encryption but I just need to fix this problem for decryption where I am told, after running the program, that the string index is out of range. Could someone please let me know what i need to change it to, I would be extremely grateful if you could. edit: I have changed the part of the code that was causing the string index problem but now, when processing decryption, the output is a blank line with 'None' beneath it and no error. edit: ord(_key_text

Vigenere cipher not working

情到浓时终转凉″ 提交于 2020-01-05 02:29:14
问题 So my teacher created this vigenere cipher and he said it was working. However, after checking its results with online vigenere ciphers it appears to not be resulting with the correct encryptions. I have no idea how to fix it and I was wondering if someone could direct me to the errors, and tell me how to fix them. Here is the code base = ord("a") alphabets = 'abcdefghijklmnopqrstuvwxyz' keyword = input('What is your keyword') message = input('What is your message to be coded or encoded?')

Vigenere Cipher Black Hawk Down

淺唱寂寞╮ 提交于 2019-12-25 19:58:30
问题 I cannot figure out why this thing doesn't scramble correctly. I read some other posts on this cipher and as far as I can tell I'm using the exact same algorithm as they are... The areas commented out are tests I tried to make sure everything was passing through correctly. I believe it all goes through correctly then fails in the algorithm. #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> string get_message(void); string scramble(string key,

Vigenere Cipher Black Hawk Down

孤街浪徒 提交于 2019-12-25 19:58:07
问题 I cannot figure out why this thing doesn't scramble correctly. I read some other posts on this cipher and as far as I can tell I'm using the exact same algorithm as they are... The areas commented out are tests I tried to make sure everything was passing through correctly. I believe it all goes through correctly then fails in the algorithm. #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> string get_message(void); string scramble(string key,

Explaining functions of Vigenère cipher

对着背影说爱祢 提交于 2019-12-25 02:19:40
问题 i found the following code at http://rosettacode.org for the Vigenère cipher and i would like to undestand it better. Could someone explain me what the single lines of code in function ordA(a) and in function(a) do? function ordA(a) { return a.charCodeAt(0) - 65; } // vigenere function vigenere2(text, key, decode) { var i = 0, b; key = key.toUpperCase().replace(/[^A-Z]/g, ''); return text.toUpperCase().replace(/[^A-Z]/g, '').replace(/[A-Z]/g, function(a) { b = key[i++ % key.length]; return

What's wrong with my vigenere cypher encrypt function?

橙三吉。 提交于 2019-12-24 21:32:59
问题 I get the error string index out of range inside of the encrypt function I don't know how to get rot to repeat over text. the code only works when both inputs are the same length. i want to keep the alphabet_position and the rotate_character functions the same if i can. alpha_lower_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] alpha_upper_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",

How can I make my Vigenère Cipher ignore spaces in the original message

早过忘川 提交于 2019-12-18 09:46:48
问题 Im trying to make a Vigenère Cipher but I can't seem to find a way to implement a feature that ignores in-putted white spaces when entering the message and then printing the final for example: I enter the starting message: "python computing" then I enter the key as: "stack" I expect to get if the program ignores spaces in the original message: "isukzg wppannjqr" but instead I get: "isukzgwppannjqr". Anyone know how I can solve this. I have considered using ords but I havent found a way to

Byte Vigenere Cipher, error with decryption

喜欢而已 提交于 2019-12-14 03:54:14
问题 I have to write a Vigenere encryption / decryption function that operates on full bytes (to encrypt and send files over tcp and then decrypt on the other side). My encrypting function seems to be working (more or less, can't really test it without decrypting function). This is the code of the encrypting function: public static Byte[] encryptByteVigenere(Byte[] plaintext, string key) { Byte[] result= new Byte[plaintext.Length]; key = key.Trim().ToUpper(); int keyIndex = 0; int keylength = key

vigenere cipher - not adding correct values

放肆的年华 提交于 2019-12-13 10:00:13
问题 I want to get specific values from a for loop to add to another string to create a vigenere cipher. here's the code. userinput = input('enter message') keyword = input('enter keyword') new = '' for a in keyword: pass for i in (ord(x) for x in userinput): if 96 < i < 123: #lowercase new += chr(97 + (i+ord(a)-97)#keeps all values in alphabet print(new) so the answer i want if i do 'abcd' as my message and 'ab' as my keyword the desired outcome is 'bddf' as 'a' + 'a' is 'b' and 'b' + 'b' = 'd'