Is there already a rot13()
and unrot13()
implementation as part of one of the standard Java libraries? Or do I have to write it myself and "reinvent the wheel"?
It might look something like this:
int rot13 ( int c ) {
if ( (c >= 'A') && (c <= 'Z') )
c=(((c-'A')+13)%26)+'A';
if ( (c >= 'a') && (c <= 'z') )
c=(((c-'a')+13)%26)+'a';
return c;
}
I don't think it's part of Java by default, but here's an example of how you can implement it;
Source: http://introcs.cs.princeton.edu/java/31datatype/Rot13.java.html