You are viewing a single comment's thread. Return to all comments →
Java solution:
public static String caesarCipher(String s, int k) { char[] chars = s.toCharArray(); for(int i=0; i<chars.length;i++){ if (chars[i]-'a'>=0 && chars[i]-'a'<26) chars[i]=(char)((chars[i]-'a'+k)%26+'a'); else if (chars[i]-'A'>=0 && chars[i]-'A'<26) chars[i]=(char)((chars[i]-'A'+k)%26+'A'); } return String.valueOf(chars); }
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
Java solution: