Java rot13 Hash rot13(String s)

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

Description

rot

License

Open Source License

Declaration

public static String rot13(String s) 

Method Source Code

//package com.java2s;
/*/*from w  w  w .  j  av a2  s.  c om*/
 * Copyright (c) 2008-2015 Geode Systems LLC
 * This Software is licensed under the Geode Systems RAMADDA License available in the source distribution in the file 
 * ramadda_license.txt. The above copyright notice shall be included in all copies or substantial portions of the Software.
 */

public class Main {
    /**
     */
    public static String rot13(String s) {
        StringBuilder sb = new StringBuilder();
        int offset = 13;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ((c >= 'a') && (c <= 'm')) {
                c += offset;
            } else if ((c >= 'A') && (c <= 'M')) {
                c += offset;
            } else if ((c >= 'n') && (c <= 'z')) {
                c -= offset;
            } else if ((c >= 'N') && (c <= 'Z')) {
                c -= offset;
            }
            sb.append(c);
        }

        return sb.toString();
    }

    /**
     * _more_
     *
     * @param sb _more_
     * @param s _more_
     *
     * @return _more_
     */
    public static Appendable append(Appendable sb, String s) {
        try {
            sb.append(s);

            return sb;
        } catch (java.io.IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }

    /**
     * _more_
     *
     * @param o _more_
     *
     * @return _more_
     */
    public static String toString(Object o) {
        if (o == null) {
            return "";
        }

        return o.toString();
    }
}

Related

  1. rot13(final byte b)
  2. rot13(String _input)
  3. rot13(String argInput)
  4. rot13(String input)
  5. rot13(String input)
  6. rot13(String string)
  7. rot13(String text)
  8. rot13(String value)