Caesar暗号を解読するプログラムを作り,暗号を解読してください

プログラミングスレまとめ in VIPの練習問題を解いてみた
練習問題 - プログラミングスレまとめ in VIP

import java.util.*;

class Caesar {
	private static final String ANGO = "qdq-gi.q-a ziatmxxitmdqibtqi-ustbi ri.qmoqrcxi.qbubu zir -ibtqi-qp-qaai ripmymsqkir -ibtqi-qy dmxi ri.cnxuoi rruoumxakir -ibtqiqzmobyqzbkii-q.qmxi -imyqzpyqzbi rixmeaki -puzmzoqai -i-qscxmbu zaimzpir -i btq-iymbbq-a;iz -iatmxximzgi.q-a zinqiuzimzgiemgipuao-uyuzmbqpimsmuzabir -ia. za -uzsiacotiimi.qbubu zj";
	private static final String DICTIONARY = "abcdefghijklmnopqrstuvwxyz .,-";
	private static final String SEARCH = "person";
	
	private static String shiftChar(String ori_str, int index) {
		String new_str = "";
		
		for (int i = 0; i < ori_str.length(); i++) {
			char c = ori_str.charAt(i);
			int match_index = DICTIONARY.indexOf(c);

			//ori_strをDICTIONARYを使いindex分だけシフトさせる(-の次はaになる)
			if (0 <= match_index) c = DICTIONARY.charAt((match_index + index) % DICTIONARY.length());
			new_str += c;
		}
		
		return new_str;
	}
	
	public static void main(String[] args) {
		for (int i = 0; i < DICTIONARY.length(); i++) {
			String shift_char = shiftChar(ANGO, i);
			if (0 < shift_char.indexOf(SEARCH)) {
				System.out.println(shift_char + "\n*ずらした文字は " + i);
				break;
			}
		}
	}
}

これは、結構時間がかかってしまいました。かなり面白かったです。