Java rot13 Hash rot13(String _input)

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

Description

Simple rot13 implementation.

License

Open Source License

Parameter

Parameter Description
_input input to scramble

Return

scrambled input (null if input was null)

Declaration

public static String rot13(String _input) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//w  w w.  ja v  a  2  s  .  com
     * Simple rot13 implementation.
     *
     * @param _input input to scramble
     * @return scrambled input (null if input was null)
     */
    public static String rot13(String _input) {
        if (_input == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < _input.length(); i++) {
            char c = _input.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;
            }
            sb.append(c);
        }
        return sb.toString();
    }
}

Related

  1. rot13(final byte b)
  2. rot13(String argInput)
  3. rot13(String input)
  4. rot13(String input)
  5. rot13(String s)