Here you can find the source of rot13(String _input)
Parameter | Description |
---|---|
_input | input to scramble |
public static String rot13(String _input)
//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(); } }