Here you can find the source of rot13(String string)
public static String rot13(String string)
//package com.java2s; /******************************************************************************* * Copyright (c) 2014 Matthieu Helleboid. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * /*from w ww .j av a 2 s.c om*/ * Contributors: * Matthieu Helleboid - initial API and implementation ******************************************************************************/ public class Main { public static String rot13(String string) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (c >= 'a' && c <= 'm') c += 13; else if (c >= 'A' && c <= 'M') c += 13; else if (c >= 'n' && c <= 'z') c -= 13; else if (c >= 'N' && c <= 'Z') c -= 13; builder.append(c); } return builder.toString(); } }