Java rot13 Hash rot13(String string)

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

Description

rot

License

Open Source License

Declaration

public static String rot13(String string) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Matthieu Helleboid.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * /*from  w ww  .j av  a  2 s.c om*/
 * Contributors:
 *     Matthieu Helleboid - initial API and implementation
 ******************************************************************************/

public class Main {
    public static String rot13(String string) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < string.length(); i++) {
            char c = string.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;
            builder.append(c);
        }
        return builder.toString();
    }
}

Related

  1. rot13(String _input)
  2. rot13(String argInput)
  3. rot13(String input)
  4. rot13(String input)
  5. rot13(String s)
  6. rot13(String text)
  7. rot13(String value)