Here you can find the source of rot13(String argInput)
Parameter | Description |
---|---|
argInput | a parameter |
public static String rot13(String argInput)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww. ja v a 2s .c o m*/ * Dummy Rot13 encryption. * * Example: * <pre> * System.out.println(rot13("helloTHERE123!")); // output: uryybGURER123! * System.out.println(rot13("uryybGURER123!")); // output: helloTHERE123! * </pre> * * @param argInput * @return */ public static String rot13(String argInput) { String ret = ""; for (int i = 0; i < argInput.length(); i++) { char ch = argInput.charAt(i); int dif = 0; if ((ch >= 'A' && ch <= 'M') || (ch >= 'a' && ch <= 'm')) { dif = 13; } if ((ch >= 'N' && ch <= 'Z') || (ch >= 'n' && ch <= 'z')) { dif = -13; } ch += dif; ret += ch; } // for return ret; } }