Crypto: Caesar Cipher explained | Java implementation

  Рет қаралды 8,170

The CS Revelation

The CS Revelation

Күн бұрын

Пікірлер: 21
@ernestobcoa2009
@ernestobcoa2009 2 жыл бұрын
Hello everyone, Thanks a lot for this lesson!! I updated the encryption part a little, because we have to consider the cases regarding uppercase letters and special characters. So, without to convert the plainText string in lowercase, this is the new encryption part (tested with success in HackerRank): public static String caesarCipher(String plainText, int shift) { String alphabet = "abcdefghijklmnopqrstuvwxyz"; String encryptedText = ""; for (int i = 0; i < plainText.length(); i++) { if (Character.isLetter(plainText.charAt(i))) { if (Character.isUpperCase(plainText.charAt(i))) { int charIndex = alphabet.indexOf(Character.toLowerCase(plainText.charAt(i))); int newIndex = (charIndex + shift) % 26; char encryptedChar = Character.toUpperCase(alphabet.charAt(newIndex)); encryptedText += encryptedChar; } else { int charIndex = alphabet.indexOf(plainText.charAt(i)); int newIndex = (charIndex + shift) % 26; char encryptedChar = alphabet.charAt(newIndex); encryptedText += encryptedChar; } } else { encryptedText += plainText.charAt(i); } } return encryptedText; } Hoping to be useful for everyone.
@periphx
@periphx 3 жыл бұрын
thank you very much !!! you helped me a lot thanks
@bayareamountainbiker
@bayareamountainbiker Жыл бұрын
how do you keep the case of the letter and codify it as the same time?
@jeanwill69
@jeanwill69 2 жыл бұрын
Thank you very much.
@peternjenga7234
@peternjenga7234 2 жыл бұрын
Hi I am using intelij IDEA to run the code and it is showing no values for the cipher text and decoded message. What can be the problem.
@dogaaykol9297
@dogaaykol9297 3 жыл бұрын
what would have happened if you input something with a space or a special characters thank you
@thecsrevelation
@thecsrevelation 3 жыл бұрын
Hi in this example. Spaces and special characters are not being handled. In this case, you will get an incorrect output. The code to handle other characters could be added.
@peterkomagum9638
@peterkomagum9638 3 жыл бұрын
Amazing
@thecsrevelation
@thecsrevelation 3 жыл бұрын
package caesarcrypto; import java.util.Scanner; public class CaesarCrypto { static String alphabet = "abcdefghijklmnopqrstuvwxyz"; public static String encoding(String pText, int Key){ pText = pText.toLowerCase(); String cText =""; for(int i = 0; i
@pavansandhu8763
@pavansandhu8763 2 жыл бұрын
my decoding doesn't work. It returns a single character multiple times.
@aarushi740
@aarushi740 3 жыл бұрын
Hi, i tried to run the same code on bluej and each time I enter a string and a key, it gives a string out of bounds exception, why is that happening?
@thecsrevelation
@thecsrevelation 3 жыл бұрын
package caesarcrypto; import java.util.Scanner; public class CaesarCrypto { static String alphabet = "abcdefghijklmnopqrstuvwxyz"; public static String encoding(String pText, int Key){ pText = pText.toLowerCase(); String cText =""; for(int i = 0; i
@sara-12MS
@sara-12MS 3 жыл бұрын
When I write the email it disappears
@thecsrevelation
@thecsrevelation 3 жыл бұрын
package caesarcrypto; import java.util.Scanner; public class CaesarCrypto { static String alphabet = "abcdefghijklmnopqrstuvwxyz"; public static String encoding(String pText, int Key){ pText = pText.toLowerCase(); String cText =""; for(int i = 0; i
@sara-12MS
@sara-12MS 3 жыл бұрын
@@thecsrevelation thanks
@sara-12MS
@sara-12MS 3 жыл бұрын
Please the code Send my
@thecsrevelation
@thecsrevelation 3 жыл бұрын
Email?
@afrdthzna3851
@afrdthzna3851 2 жыл бұрын
@@thecsrevelation can yu please explain other ciphers too
@thecsrevelation
@thecsrevelation 2 жыл бұрын
@@afrdthzna3851 i have two more explained in this video kzbin.info/www/bejne/eneuk3WknLxrmdk
@allankibichiilimo1606
@allankibichiilimo1606 3 жыл бұрын
**********
@thecsrevelation
@thecsrevelation 3 жыл бұрын
package caesarcrypto; import java.util.Scanner; public class CaesarCrypto { static String alphabet = "abcdefghijklmnopqrstuvwxyz"; public static String encoding(String pText, int Key){ pText = pText.toLowerCase(); String cText =""; for(int i = 0; i
Cryptography 101 for Java developers by Michel Schudel
42:59
Java encryption program 🔑
32:06
Bro Code
Рет қаралды 46 М.
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 71 МЛН
Human vs Jet Engine
00:19
MrBeast
Рет қаралды 208 МЛН
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
Amazing remote control#devil  #lilith #funny #shorts
00:30
Devil Lilith
Рет қаралды 15 МЛН
Caesar Cipher (Part 1)
13:23
Neso Academy
Рет қаралды 548 М.
the TRUTH about C++ (is it worth your time?)
3:17
Low Level
Рет қаралды 758 М.
Python Beginner Project: Build a Caesar Cipher Encryption App
25:10
AES: How to Design Secure Encryption
15:37
Spanning Tree
Рет қаралды 170 М.
Cracking Enigma in 2021 - Computerphile
21:20
Computerphile
Рет қаралды 2,5 МЛН
XOJO: Variables | Data Types | Create | Use
43:06
The CS Revelation
Рет қаралды 408
C++ Caesar Cipher (ASCII Codes) | Algo for Beginners
13:39
Errichto Algorithms
Рет қаралды 48 М.
Public Key Cryptography - Computerphile
6:20
Computerphile
Рет қаралды 903 М.
7 Cryptography Concepts EVERY Developer Should Know
11:55
Fireship
Рет қаралды 1,3 МЛН
The Strange Physics Principle That Shapes Reality
32:44
Veritasium
Рет қаралды 6 МЛН
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 71 МЛН