Java rot13 Hash rot13(String argInput)

Here you can find the source of rot13(String argInput)

Description

Dummy Rot13 encryption.

License

Open Source License

Parameter

Parameter Description
argInput a parameter

Declaration

public static String rot13(String argInput) 

Method Source Code

//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;
    }
}

Related

  1. rot13(final byte b)
  2. rot13(String _input)
  3. rot13(String input)
  4. rot13(String input)
  5. rot13(String s)
  6. rot13(String string)