Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
9
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

ROT13

ROT13

ROT13(rotate by 13 places)
文字を任意の個数ずらすシーザー暗号の一種で、13字ずらす方式。
アルファベットが26字なので、13字ずらすことを2回やると元に戻る。
暗号化と復号化が同じ仕組でできる。

Python

stringのencodeメソッドを使う






"ABC".encode('rot13')
'NOP'

2回適用すると元に戻る

"ABC".encode('rot13').encode('rot13')
'ABC'

encodeで指定できるコーデック一覧

BASE64もあるよ

Linux

trによる変換


$ echo ABC | tr A-Z N-ZA-M
NOP

nkfによる変換

$ echo ABC | nkf -r
NOP

nkfを使ってファイルごと変換

$ cat text
ABC
$ nkf -r text 
NOP

vi


VISUALモードなどで選択して、
g?
を入力

2回実施すると戻る

参考文献

ROT13, wikipedia
http://en.wikipedia.org/wiki/ROT13

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
9
Help us understand the problem. What are the problem?