vigenere

Vigenere Cipher c# with “ñ”

北城余情 提交于 2019-12-13 09:54:41
问题 I'm making a program of Vigenere cipher in c # but I'm having a problem i don't have the "Ñ" I would like to encrypt as happens in Vigenere cipher but With the "Ñ" how add the letter "Ñ" to this code? such that both key and s remain this way: a=0 b=1... n=13 ñ=14... z=26 after the n that a place be flown using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void VigenereEncrypt(ref StringBuilder s, string

itertools cycle in vigenere cipher causing problems with spaces python

流过昼夜 提交于 2019-12-13 05:20:59
问题 In my code for vigenere cipher I use cycle from itertools to cycle through the key word. This works great until I use spaces in the message as it encrypts the space therefore making the encryption wrong. Here is the code. message = input('enter message: ') keyword = input('enter keyword: ') def chr_to_int(char): return 0 if char == 'z' else ord(char)-96 def int_to_chr(integer): return 'z' if integer == 0 else chr(integer+96) def add_chars(a, b): return int_to_chr(( chr_to_int(a) + chr_to_int

Encrypt byte array using vigenere cipher in java

风格不统一 提交于 2019-12-13 04:50:42
问题 I have to encrypt some file (jpg) using vigenere cipher. I wrote some code, but after encryption and decryption my file is corrupted. The first 1/4 of image displays okay, but the rest of it is corrupted. Here is my code: @Override public byte[] encryptFile(byte[] file, String key) { char[] keyChars = key.toCharArray(); byte[] bytes = file; for (int i = 0; i < file.length; i++) { int keyNR = keyChars[i % keyChars.length] - 32; int c = bytes[i] & 255; if ((c >= 32) && (c <= 127)) { int x = c -

How do i force my code to print in python

我只是一个虾纸丫 提交于 2019-12-12 10:27:13
问题 I'm having trouble trying to work out an error in my code. It isn't printing the final product and leaving a blank space. playing = True string = "" Alphabet = ('z','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') while playing == True: string = "" eord = input('Type "d" to "decrypt" and "e" to "encrypt": ') if eord == 'e': texte = input ("Type your word to encrypt: ") key1 = int(input("Choose a key between 1-26:

Vigenère cipher in Java for all UTF-8 characters

China☆狼群 提交于 2019-12-12 10:01:32
问题 I have this simple function for encrypting strings via Vigenère in Java. I omitted the decryption as this is just a "-" instead of the "+" in the line where the new value is calculated. But this function works only for the normal alphabet A-Z. How can I change the function so that it supports lowercase letters as well as uppercase letters and all other UTF-8 chars? public static String vigenere_encrypt(String plaintext, String key) { String encryptedText = ""; for (int i = 0, j = 0; i <

Vigenere Cipher only works up until dealing with a space(“ ”) in C - why?

╄→гoц情女王★ 提交于 2019-12-12 06:50:08
问题 #include <stdio.h> #include <cs50.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main(int argc, string argv[]) { string k = argv[1]; string s = GetString(); int l = strlen(k); for(int i = 0, n = strlen(s); i < n; i++) { if(s[i] >= 65 && s[i] <= 90) { int i2 = ((s[i]-65) + (k[i%l]-97)) % 26; printf("%c", i2+65); } else if(s[i] >= 97 && s[i] <= 122) { int i2 = ((s[i]-97) + (k[i%l]-97)) % 26; printf("%c", i2+97); } else { printf("%c", s[i]); } } printf("\n"); return 0; } I

How to reuse(loop) key in vigenere cipherkey cs50 pset2

旧巷老猫 提交于 2019-12-12 04:55:36
问题 I was making a program for Vigenere cipher. I made the program print the cipher text successfully. But, I can't loop the key. so if my key was 'abc' and my plain text was hello, it should print 'hfnlp' not 'hfn'. #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { if(argc != 2) { printf("\aError\n"); return 1; } else { string a = argv[1]; // converts argv[1] printf("plaintext: "); string b = get_string(); // takes the plaintext

How can I write vigenere cryptanalysis of persian text?

点点圈 提交于 2019-12-12 04:17:25
问题 How can I write Vigenere cryptanalysis for persian language? Is there any sample source code for persian? 回答1: I was unable to find a Persian-language version of Vignere cryptanalysis. You could try one of the solutions here and adapt the alphabet used to the persian alphabet. (You'll need persian-language letter usage statistics, it won't work with english ones.) I recommend the python but that's just personal taste. 来源: https://stackoverflow.com/questions/34795192/how-can-i-write-vigenere

Modified Vigenere Cipher in python - Alphabet

无人久伴 提交于 2019-12-11 17:26:08
问题 This is what I have to do: Write a script in Python that is an implementation of a version of the Vigenere cipher for English text. Your script should distinguish lowercase and uppercase letters (i.e., the encryption key and the plaintext are allowed to be composed of lowercase and uppercase letters but the ciphertext should be uppercase). In addition to letters, there will be four other characters in the plain text: comma (26), dot (27), dash (28), underscore (29) changing the encryption

ASCII Vigenere cipher not decrypting properly

馋奶兔 提交于 2019-12-11 12:35:10
问题 My Vigenere cipher program has all come down to two lists. One a list of ASCII numbers which represent the characters of the message to be encrypted/decrypted and the other is a list of ASCII numbers of the key that would be used to decrypt/encrypt the message. For encryption: encryption = [((x + y) % 26) + ord('A') if x < 128 else x for x, y in zip(msglist, keylist)] for decryption: encryption = [((x - y) % 26) + ord('A') if x < 128 else x for x, y in zip(msglist, keylist)] If I input