What are some practical applications of the ROT13 algorithm?

我与影子孤独终老i 提交于 2019-12-12 10:59:05

问题


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 useful cases where ROT13 is used?


回答1:


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.




回答2:


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()));
});


来源:https://stackoverflow.com/questions/3928903/what-are-some-practical-applications-of-the-rot13-algorithm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!