How to encrypt messages (Caesar cipher) - C Programming
Vložit
- čas přidán 9. 05. 2020
- Going over a coding problem which requires us to encrypt text using a Caesar cipher, and solving it with the help of the C programming language.
Please Like & Subscribe if you found this interesting.
Looking forward to your comments below.
Code: github.com/BudacaB/yt/tree/ma...
Caesar cipher: en.wikipedia.org/wiki/Caesar_...
#cprogramming #cprogrammingtutorial #cprogrammingforbeginners #programming #coding #developer #howto #tutorial #cs #bogdanbudaca - Věda a technologie
If you enjoyed the video and what I am doing on this channel, consider buying me a warm cup of coffee ☕❤️
www.paypal.com/donate?hosted_button_id=R8EXVLT5HFBYE
Awesome video, please keep doing more videos like this one!!
Thanks a lot, cheers
Thanks for ur clear n straightforward approach, much easier to understand.
Glad you liked it :)
Excelent explanation! Very clear on your thoughts! It was very helpful!
Glas to hear Lucas, cheers
Thanks, man, you are very clear.
Glad you liked it :)
Muy buena tu forma de explicar,no entiendo como alguien tan genial tiene tan poco reconocimiento,te deseo éxitos y muchas gracias por la explicación :)
Gracias
I am so grateful!!! May lord bless you mr. Bogdan : )
but i have a doubt, what if the user enters 'x' as a key, so the atoi converts it to an int value 0...so keeping that in mind conversion of key to int shouldnt be done before we validate the key. am i right? please help :(
Cheers, Abeer
Yes, you are right, it would be better to check if the key is made of digits first, I didn't know that atoi returns 0 if it can't convert. Thank you for pointing it out
thank you sir
thanks sir i appreciate your efforts
How to Implement Caesar cipher using programming language C, It should
include the functions for both encryption and decryption. Includes comments to explain
the important steps in the algorithm
can you please clear this question to me?
Hi Vincent, might try and do a video for decryption as well soon, thank you for the idea, haven't really looked into it yet
@@BogdanBudaca thankyou try it soon because I want to know this answer
Thanks a lot for this video, it was really helpful and learned a lot!
Just one thing I didn't really get, why do we have to subtract and add 65 and 97 when we are applying the formula? Could you please point to some more detailed explanation?
Thank you, glad you liked it. It might help testing for an upper edge, say Z is 90 in ASCII. The trick is that having 26 letters in the alphabet, we want our new value, with the key, to land in the same range. So if we deduct 65 from 90 to take it to the 0-26 range, then add say a key of 3, we get 28. If we add back the 65 now, we'd get 93 for ASCII. That would give us ']', instead of circling back to a letter, this is where the modulo 26 comes in. So basically this is a way to circle back to letters for the upper edge letters, or a big key; hope this makes some sense. Cheers
please in this part
// check validity of the key
for (int i = 0; i < strlen(argv[1]); i++)
{
if (isdigit(argv[1][i]))
{
valid_key = true;
he gives
[Error] Initial 'for' loop declarations are only allowed in C99 or C11 mode
Hey there, please google your error, stackoverflow should be the first result, with a fix 🤙
1 question : the purpose of
fgets(input, sizeof(input), stdin);
How this differs with get string ? Thanks
They serve the same purpose, getting string input, but get_string() is provided only by Harvard's cs50.h library to be a bit more friendly.
Outside of that environment you might look at fgets()
man.cs50.io/3/get_string
www.geeksforgeeks.org/fgets-gets-c-language/
Thanks for ur replies. I better understand now
How would I incorporate opening an existing file and writing the results to a new file before the offset?
Hi, if you're on Linux for example it's pretty easy with redirection, pass the key, input from a file and output to some other file, e.g. ./caesar [key] < [input.txt] > [output.txt].
Hope this is what you mean, you could also tweak the code to include some file reading / writing capabilities and you could pass the input file as an argument, this could help www.programiz.com/c-programming/c-file-input-output
why we use return 1 ????????????
I don't believe this works properly if the user inputs a negative integer for their key. Any suggestions?
Hi and thank you, yup that wasn't in the scope of the exercise, I think you could mitigate it in the arguments check, or in some other way you see fit.
1 more : difference between
Return 0;
Return 1;
When to use which ? Thanks
By convention, when a program terminates successfully, it returns 0; anything other than 0, including 1, means there's an error and that could be the error code (returned also with an error description)
Why is it saying "called object type 'bool' is not a function or function pointer" for me?
Are you trying to call a variable of type 'bool' as a function? Found this on Google: stackoverflow.com/questions/19733090/error-called-object-type-int-is-not-a-function-or-function-pointer
This wouldn't work if the key was -100, can someone explain why?
It has to do with the isdigit() function which does the checking, it can't receive a '-' character
which os is that
Ubuntu 20.04
‘Scuse me Mr. Bald friendly Guy, Hey There, can you do some simple, run of the mill, basic of the basic stuff, like what is a { and what program are you using, and btw why do you have that piercing?
Hi Andrei, thank you for the suggestion, I might be looking at going over basic notions in a video
The piercing is just a personal thing :)
but how to decript? text
Oh that might be a good idea for a vid, thank you