caesar-cipher

C# Caesar Shift decryption stops showing shifts after a number of shifts and shifts get longer

岁酱吖の 提交于 2019-12-11 09:51:47
问题 I am developing a Ceaser Cipher which decrypts the .TXT file attached. It's got to show all possible shifts and results in the decrytped text. But what I have got so far just shows about 8 shifts and each shift is getting longer with more text which is not meant to happen. Can someone help me identify the problem in the below code? public class Program { public static void Main(string[] args) { string text = System.IO.File.ReadAllText(@"FilePath"); string file; int shift = 0; string decoded

Caesar Cipher Java Program can't shift more than 23

故事扮演 提交于 2019-12-11 07:38:13
问题 I'm creating a program to do a Caesar Cipher , which shifts the letters in a word one time when I hit enter, and prompts the user to shift again or quit. It works until I get to 23 shifts , then it starts using non-letter symbols for some reason, and I'm not sure why this is happening. Any suggestions? Here is the code: import java.io.File; import java.io.IOException; import java.util.Scanner; public class Cipher { public static void main(String[] args) { // encrypted text String ciphertext;

How to advance string 3 letters in the alphabet (Caesar cipher)?

有些话、适合烂在心里 提交于 2019-12-11 04:25:54
问题 I'm trying to make a program that encrypts a string the user submits. I want to use an encryption technique where the string is advanced 3 letters in the alphabet. Example: abc would become def . Currently I have a TextBox ( TextBox1 ) and a Button ( Button1 ). My code so far: Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim rawText As String rawText = TextBox1.Text Dim letterTxt As String = Chr(Asc(rawText) + 3) MsgBox(letterTxt) End Sub The problem is

Function That Receives and Rotates Character - Caesar Cipher

早过忘川 提交于 2019-12-09 22:48:23
问题 I'm trying to create a function rotate_character(char, rot) that receives a character, "char" (a string with a length of 1), and an integer "rot". The function should return a new string with a length of 1, which is the result of rotating char by rot number of places to the right. So an input of "A" for char and "13" for rot would return N (with A having an initial value of 0, and B having an initial value of 1, etc). Capitalization should be maintained during rotation. I already created a

Cant shift Caesar Cipher by more than 1 [closed]

≡放荡痞女 提交于 2019-12-08 03:39:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am new to Java and I have to make a Caesar Cipher program. This is my code. The problem I am having is that I cannot shift it by more than 1. For ex, if I write 'help me' and enter shift value of 2 it still only shifts by 1 --> 'ifmq nf' public static void main(String[] args) { Scanner sc=new Scanner(System.in

Function That Receives and Rotates Character - Caesar Cipher

雨燕双飞 提交于 2019-12-04 15:27:03
I'm trying to create a function rotate_character(char, rot) that receives a character, "char" (a string with a length of 1), and an integer "rot". The function should return a new string with a length of 1, which is the result of rotating char by rot number of places to the right. So an input of "A" for char and "13" for rot would return N (with A having an initial value of 0, and B having an initial value of 1, etc). Capitalization should be maintained during rotation. I already created a function that returns the position of a letter in the alphabet by using a dictionary: letter = input(

Encryption and Decryption within the alphabet - Python GCSE

限于喜欢 提交于 2019-12-02 13:36:06
I am currently trying to write a program, for school, in order to encrypt and decrypt a inputted message. I need the encrypted or decrypted message to only be in the alphabet no other symbols or keys, for example, with an inputted offset of 5 using the message van to encrypt, i want it to output 'afs'. Can anyone help please? This is my code currently. def find_offset(): offset = int(input("Enter an offset: ")) if offset > 25 or offset < 0: print("Invalid offset, please enter another offset: ") find_offset() else: print("Okay") encrypt_fun(offset) def encrypt_fun(offset): choice = '' while

How can I get sed to change all of the instances of each letter only once?

丶灬走出姿态 提交于 2019-12-01 14:35:10
So far, the code only changes the first letter. If I take the break out, then it changes each instance of a letter more than once (which is bad). I'm simply attempting a caesar cipher using sed. I realize I could use tr to perform text transformations, but I'd prefer to stick with sed. echo "What number do you want to use for the shift?" read num declare -A origin x=({a..z}) case "$num" in 0) y=({a..z});;1)y=({{b..z},a});;2)y=({{c..z},a,b});;3)y=({{d..z},a,b,c});;4)y=({{e..z},a,b,c,d});;5)y=({{f..z},{a..e}});; 6)y=({{g..z},{a..f}});;7)y=({{h..z},{a..g}}) ;; 8) y=({{i..z},{a..h}}) ;; 9) y=({{j.

How can I get sed to change all of the instances of each letter only once?

五迷三道 提交于 2019-12-01 12:14:54
问题 So far, the code only changes the first letter. If I take the break out, then it changes each instance of a letter more than once (which is bad). I'm simply attempting a caesar cipher using sed. I realize I could use tr to perform text transformations, but I'd prefer to stick with sed. echo "What number do you want to use for the shift?" read num declare -A origin x=({a..z}) case "$num" in 0) y=({a..z});;1)y=({{b..z},a});;2)y=({{c..z},a,b});;3)y=({{d..z},a,b,c});;4)y=({{e..z},a,b,c,d});;5)y=(

How do you handle the shift on a Caesar cipher in Javascript?

十年热恋 提交于 2019-11-29 17:58:13
I'm trying to create a caesar cipher in Javascript and having trouble figuring out how to do the shift. It may be that my approach is complicating it, but I'm trying to understand how to set a max value for adding numbers, but have the addition continue starting from the minimum number. Here is the code I have: $(document).ready(function(){ var alpha = []; var encoded = []; alpha = { '1': 'a', '2': 'b', '3': 'c', '4': 'd', '5': 'e', '6': 'f', '7': 'g', '8': 'h', '9': 'i', '10': 'j', '11': 'k', '12': 'l', '13': 'm', '14': 'n', '15': 'o', '16': 'p', '17': 'q', '18': 'r', '19': 's', '20': 't',