Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

0
votes
0answers
32 views

Iteration over permutations - pset2: crack

To do 'crack' in pset2, I want to iterate over every permutation of letters of an alphabet in an array of a certain size n (n=3 in the code below). A possible solution would be using n nested loops. ...
0
votes
0answers
60 views

Vigenere Output bug

I feel that I'm making steps that shouldn't be done and ignoring some handy steps that need to be used, I'm trying to validate my code step by step but I spent to much time trying to solve vigenere ...
0
votes
1answer
33 views

Help with weird bug in pset2 vigenere

After finishing most of the program, for some reason when check50 attempts to encrypt BaRFoo using keyword BaZ as well as the other attempts for the variations of barfoo and "hello, world", my code ...
1
vote
2answers
26 views

PSET 2 Vigenere - only getting symbols as output

So far in Vigenere i've gotten to the point with a single character key, and when I tried to test it, everything works except my output is entirely ����. Here is my code for the shift function and ...
0
votes
1answer
50 views

PSET 2 Crack: Getting salt from argv[1]

I think I might be misunderstanding some basic things about strings because I'm really struggling to get the salt in crack. I'm getting compile errors from the below code. I've also tried making the ...
0
votes
1answer
44 views

Problem with Pset2 submission vigenere

I just wrote the program for cs50 pset2 vigenere problem. It ran perfectly when I tried to run it, with expected output. But on submitting, cs50.me check50 shows that my program does not show the ...
0
votes
1answer
57 views

How do I validate a key in Caesar?

I'm having difficulties in validation step in Caesar. My logic here is to pass through each digit and check if it is a number character and if not, abort. If they all are, it will convert each ...
0
votes
1answer
36 views

pset 2 caesar help!

am having trouble printing the correct ciphertext, code is rather lengthy for sure but will appreciate it a lot if anyone can tell me what's the problem here! For example with a key of 1 and a ...
0
votes
1answer
81 views

pset2: vigenere.. Getting same output as the staff's solution, but still gets the score 2 out of 5.. Could some one guide me to the problem?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int shift(char c); int main(int argc, string argv[]) { // Check that ...
0
votes
1answer
42 views

Pset2 - Shifting characters in String but not getting the correct answered

i am attempting Vigenere on CS50 Pset2. I am creating a new array with same length as keyword to shift to its digit counterpart. However i am not getting the correct answer, any idea what is the ...
0
votes
2answers
27 views

Pset 2 - String is unitialized, initialize the variable to silence this warning

I am working on Caesar cipher on CS50 Week 2. I have generally wrote most part of the code but the final error message which i have not debugged was the initalizing of the string at the end. How do ...
0
votes
2answers
27 views

Crack.c Error in 2 passwords

For pset2 crack, I have managed to crack 10 of the 12 passwords given, but, the other 2 passwords are not getting cracked. Any help would be appreciated. Code: //Cracks password encrypted using ...
0
votes
1answer
19 views

PSet2 why isn't this providing output

This segment of code only prints out blank lines. Key is the correct integer, but I must be handling the array of characters incorrectly. Thoughts? int key = atoi(argv[1]); for (int i = 0, c = ...
0
votes
1answer
85 views

Checking to see if the contents of a string is an integer

Currently I am working on Caesar and validating the user inputs. The argument count section works fine. However, I can't find a way to compare the value in the vector argument string (argv[1]) to see ...
0
votes
1answer
29 views

Vigenère spitting out random strings

My vigenère is spitting out random strings. For example, here is a test I got from my terminal ~/pset2/ $ ./vigenere a plaintext: a ciphertext: G ~/pset2/ $ And my code is here. I suspect that ...
0
votes
1answer
36 views

In Vigenère, is the key case sensitive? SOLVED

Is the key in Vigenère case-sensitive? It doesn't say and I'm confused.
0
votes
1answer
43 views

crack.c: No response 😒

When I run my crack.c, the program never responds. It just sits there and wastes time. I even tried debugging it on the CS50 IDE, and it was normal. Here is my code: #include <cs50.h> #include &...
0
votes
1answer
58 views

crack.c: UndefinedBehaviorSanitizer:DEADLYSIGNAL --SOLVED--

When I run my code: #include <cs50.h> #include <stdio.h> #include <crypt.h> #include <string.h> string crack(string hashed); string deleteAll(string s, char target); // ...
0
votes
1answer
33 views

Pset 2 Vigenere

For capital letters the key seems to be behind my -6. Such that A is -6 and F is zero. :(
0
votes
1answer
26 views

pset2 Vigenere - output overwriting “ciphertext”

I'm stuck (apologies if I just didn't find the answer to this - I did read a number of answers and didn't see a solution to this problem). I have a line in my code to print "ciphertext:" before the ...
0
votes
2answers
67 views

pset2 crack: Takes too long

My code takes like 1-2 minutes to execute, and the result is always Killed. Here is my code: #include <cs50.h> #include <stdio.h> #include <crypt.h> #include <string.h> ...
0
votes
1answer
34 views

my crack.c actually works, but doesnt give away the key! Pset2

I am trying to figure out how to solve the crack problem from pset2, everything works fine with compiling but when I try to crack the hash from the example 50cI2vYkF0YU2 which is Zamayla's ...
0
votes
1answer
182 views

CS50 pset2 vigenere problem getting the shift

Problem with the shift value function ## Hi, Could anyone please take a look at the code below and help me figure out where it goes wrong. I think the problem is with the shift_value. The code ...
0
votes
1answer
36 views

why do we use remainder 26 (%26)?

Why do we keep using the %26 in pset2 when working with Caesar and Vignere? I'm having trouble understanding why it would be helpful to know what the remainder is after dividing by 26?
1
vote
1answer
72 views

Pset2 Crack - works for one password 50i2t3sOSAZtk--->(lol), but not for other passwords - why?

this version of crack works for lol, and prints the following: new hash = 50i2t3sOSAZtktr [what is the 'tr' at the end???] lol for other passwords, the program never returns a decoded pw, just ...
0
votes
1answer
76 views

pset2 Vigenere null pointer passed as argument 1, which is declared to never be null

So as stated in the title, my problem is that a null pointer is being passed to something in my Vigenere encoder. Here is my code. I will explain what I find to be the problem and give the error ...
2
votes
1answer
84 views

Caesar code only works correctly when I add a random printf statement

My Caesar code seems to be working correctly in this form: #include <cs50.h> #include <stdio.h> #include <string.h> // validates that the key is only numbers int validate_key(...
0
votes
1answer
93 views

shifting function in vigenere not working correctly

i have been trying so hard to figure out what the shifting problem is in the encrypt function but i have no clue so i would like it if any one could tell me what is happening. I have put a "----here---...
0
votes
1answer
32 views

Unable to get crypt to print correct hash

i can get crypt to print the expected hash when i put the string directly into the function. however when passing a char array in i seem to be getting a different hash. Any suggestions? char ...
0
votes
1answer
51 views

Bug? My Crack code was accepted though it doesn't work properly

Can't totally get a thing. My code was accepted and the score is 5 out of 5, however it does't work properly. After searching through the forum I inderstood that I should use strcmp() for comparing ...
0
votes
1answer
44 views

Why is my ciphertext printing random values?

I am currently working on Vigenere. I have the code to where it will work if the key is very short (a few characters), but for some reason my program bums out when the plaintext is long or the key is ...
0
votes
1answer
44 views

Why isn't my key running cyclically?

I am currently working on Vigenere, and for whatever reason my key values are running through randomly and just not working. I'm new to programming, so sorry if I am missing something major in my code ...
0
votes
1answer
56 views

Vigenere-Struggling to understand why garbage values are being printed

I'm extremely new to coding so bear with me. With my code, it, unless both the key and the plaintext are lowercase garbage values, are printed ruining the encryption of the plaintext. I struggle to ...
0
votes
1answer
57 views

check50 not approving my code but it looks like it's working

Check50 is telling me that none of the expected ciphers are working, however running each of them appears to give the exact same output it expects. I cannot see where the failure is coming from. ...
0
votes
1answer
70 views

pset2/Crack - Terminal disconnected after some time of running

My Crack program is OK, I found all passwords with 4 digits or less, but when it comes to 5 digits, after 10-20 min running my terminal gets a red message "Terminal Disconnected", and I have to start ...
1
vote
1answer
88 views

This should be right (Caesar)

After spending pretty much a whole day on this, I have gotten it to work fine, it does all that was demanded but when submitted, I am still getting 1/5 on correctness. :( someone tell me if I left ...
0
votes
1answer
287 views

Pset2 Vigenere: Pointers/Function Question

I've been having major trouble with Vigenere. I've worked on it every day for the passed two weeks and each day, I solve one problem but encounter another. I was able to get the program with the ...
1
vote
1answer
66 views

vigenere output “incompatible pointer types”

I'm trying to solve pset2 vigenere, but I'm having some troubles. I'm using two functions to adapt the key to the text and then to apply the cipher. When I run the last function, I can't get any ...
0
votes
1answer
314 views

CS50-pset2-Validating the Key-how to check or reject the user's input is decimal or not

Excuse me, When I practice the pset2 program, I follow the step at 'Validating the Key'. But I have the problem like below code, I want to compiler and output look like as $ ./caesar 20 Success ...
0
votes
1answer
44 views

How do you make a variable work in multiple loops?

I am trying to solve the vigenere.c problem, but there is one step that I need to figure out before my code works. I am stuck here and I don't know what else I could do. In my code, I have a variable ...
1
vote
1answer
110 views

Pset2 can't crack stelios password

My solution for Pset2 crack works for every password except for stelios's. I can crack other 5 character passwords (e.g., ABCDE, etc.), but for some reason, my code runs for 60m9.563s when trying to ...
0
votes
1answer
94 views

Pset2 vigenere keyword wrapping around with modulo

I have a solution for Vigenère’s cipher that passes all of the check50 tests, however I don't think my solution for how to wrap around the keyword is what the problem is looking for. Below is my code. ...
0
votes
1answer
92 views

Pset2: vigenere. Problem with key “hello, world!”

I can't solve the problem with key "hello, world!" and understand why it appears. #include <stdio.h> #include <cs50.h> #include <string.h> #include <stdlib.h> #include <...
0
votes
1answer
37 views

Pset 2 Caesar: “invalid operands to binary expression ('string' (aka 'char *') and 'int')”

I am getting the following errors and I cannot figure out why. I've managed to work out the other bugs up until this. Would someone be able to point me in the correct direction? Kind regards, Sam ...
0
votes
1answer
35 views

Pset2 Vigenere, array with garbage

I am getting some garbage values when declaring my array. I kinda understand that when declaring without initializing it provides garbage values, but I don't understand why the array is larger than ...
0
votes
1answer
53 views

Vigenere/ PSET 2/ It works for me but it can't pass the check50

Im trying to figure out where my problem is. Usind the examples given with the keys the transcription works fine. But if i try to run check50: //Checking for right argument if (argc != 2) { ...
0
votes
1answer
29 views

My cipher algo is wiping out my keyword!

When my cipher algo sees an "a" it seems to wipe out the rest of the keyword, returning only a " ", which seems to erase the rest of my keyword, leaving my encryption useless. I've debugged this ...
0
votes
1answer
27 views

Pset 2, Vigenere, Segmentation Fault - Finding Alpha - Better way to do this?

First time posting here. Still very much a beginner with this stuff. I spent more time than I care to admit recently trying to figure out how to get the command lines checks in vigenere to work. ...
0
votes
1answer
42 views

pset2 - crack - array declaration not working

I feel stupid, why is not printing "ROFL" in this program? I am testing for the crack.c program: #include <stdio.h> #include <cs50.h> //int main (int argc, string argv[]) int main (int ...
0
votes
1answer
46 views

can't check until a frown turns upside down

I am just wondering why the check result is like this: :) caesar.c exists. :( caesar.c compiles. expected exit code 0, not 1 :| encrypts "a" as "b" using 1 as key can't check until a ...