I need to write a code to encrypt any sentence in a square caesar box. So if the sentence has 28 words, the 'box'(array) should have 36 spaces. I should change s.length in my code to something that works this out, but I don't know how.
public static String encrypt(String plainText) { String s = plainText.toLowerCase(); s = s.replaceAll("\\s",""); s.toCharArray(); s.charAt(1); // This is the sencence as an array int n = s.length();// This is the size of the box int counter = 0; string [] [] box = new string [n] [];//This is the box for (int i = 0; i<n; i++){ for(int j=0; j<n; j++){ box[i][j] = s.charAt(counter); counter++; } } return box; }
Any ideas?