Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.unistuttgart.iaas.pse.ex05.p3;
- import java.util.*;
- public class Caesar {
- public static List<String> cipher(String text) {
- List<String> ciphersList = new ArrayList<String>();
- for (int shift = 0; shift <= 26; shift++) {
- String cipher = "";
- for (int i = 0; i < text.length(); i++) {
- char currentLetter = text.charAt(i);
- if (currentLetter >= 65 && currentLetter <= 90) {
- int tmpLetter = currentLetter + shift;
- if (tmpLetter > 90) {
- cipher += (char) (currentLetter + (shift - 26));
- // System.out.println(cipher);
- } else {
- cipher += (char) (currentLetter + shift);
- // ciphersList.add(i, cipher);
- // System.out.println(cipher);
- }
- } else if (currentLetter >= 97 && currentLetter <= 122) {
- int tmpLetter = currentLetter + shift;
- if (tmpLetter > 122) {
- cipher += (char) (currentLetter + (shift - 26));
- // ciphersList.add(i, cipher);
- // System.out.println(cipher);
- } else {
- cipher += (char) (currentLetter + shift);
- // ciphersList.add(i, cipher);
- // System.out.println(cipher);
- }
- } else if (currentLetter == 32) {
- cipher += " ";
- }
- }
- ciphersList.add(shift, cipher);
- }
- return ciphersList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement