开发者

What are some practical applications of the ROT13 algorithm?

What are some practical applications of the ROT13 algorithm? Since it can't be used for encryption, the only usages I've seen of it involve scrambling spoilers or answers to questions. Are there other more practical and开发者_StackOverflow useful cases where ROT13 is used?


ROT13 is used in parts of the Windows registry. The usual reason for using something like ROT13 is search. For whatever reason, they didn’t want some registry keys to show up when you did a search for “notepad.exe” or “Program Files” in the registry. So they ROT13ed them.


Per Basic symmetric encryption in action: str_rot13() from TuxRadar ROT13 can be used to obfuscate unwanted content from the end-user, i.e. spoilers and profanity, that they can then interact with to reveal the actual content.

Example implementation (JavaScript w/ jQuery, JSFiddle):

function rot13(s) {
    // credit: http://stackoverflow.com/a/617685/1481489
    return s.replace(/[a-zA-Z]/g,function(c) {
        return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);
    });
};

$('.spoilerText,.badWord').each(function(s) {
    var $this = $(this);
    $this.text(rot13($this.text()));
}).click(function() {
    var $this = $(this);
    $this.text(rot13($this.text()));
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜