作为其中一个标准Java库的一部分,是否已有rot13()
和unrot13()
实现?还是我必须自己写和“重新发明轮子”?java中的ROT-13函数?
它可能是这个样子:
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;
}
@BNL我个人比较喜欢rot104。需要专用协处理器 –
@BNL LOL谁说这是出于安全目的?请参阅[这](http://stackoverflow.com/questions/3928903/what-are-some-practical-applications-of-the-rot13-algorithm) –
顺便说一句,rot13是它自己的逆,所以你不'实际上需要一个“unrot13”方法。 –