Here you can find the source of rot13(String value)
Parameter | Description |
---|---|
value | string to rotate |
public static String rot13(String value)
//package com.java2s; public class Main { private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", LOWER = "abcdefghijklmnopqrstuvwxyz"; /**// www . j av a 2s . co m * Replace every alpha character in a string with the character 13 over * @param value string to rotate * @return rotated result */ public static String rot13(String value) { StringBuffer buffer = new StringBuffer(value.length()); int count = value.length(); int index; char c; for (int i = 0; i < count; i++) { c = value.charAt(i); if ((index = LOWER.indexOf(c)) >= 0) { buffer.append(LOWER.charAt((index + 13) % 26)); } else if ((index = UPPER.indexOf(c)) >= 0) { buffer.append(UPPER.charAt((index + 13) % 26)); } else { buffer.append(c); } } return buffer.toString(); } }