Created
March 20, 2018 08:19
-
-
Save Jabriko/39dcbd4a59df999fd2ae2cfebc56ed87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package id.indrasudirman.bahanujicoba; | |
| /** | |
| * Created by Jabrikos on 3/16/2018. | |
| */ | |
| public class Rot13 { | |
| public static String rot13 (String value) { | |
| char[] values = value.toCharArray(); | |
| for (int i = 0; i < values.length; i++) { | |
| char letter = values[i]; | |
| if (letter >= 'a' && letter <= 'z') { | |
| // Rotate lowercase letters. | |
| if (letter > 'm') { | |
| letter -= 13; | |
| } else { | |
| letter += 13; | |
| } | |
| } else if (letter >= 'A' && letter <= 'Z') { | |
| // Rotate uppercase letters. | |
| if (letter > 'M') { | |
| letter -= 13; | |
| } else { | |
| letter += 13; | |
| } | |
| } | |
| values[i] = letter; | |
| } | |
| // Convert array to a new String. | |
| return new String(values); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment