Pythonによるシフト暗号の復号

Pythonによる文字コードに2を加えた暗文の復号方法

Pythonを起動(ライン入力モード)

C:\ToolZ\python27>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

変数eにコピーした暗文をセット

>>> e = 'R{vjqp"ku"xgt{"wughwn#' 

変数dに暗文eの各文字コードから2を引いた結果をセット

>>> d = "".join([chr(ord(e[x])-2) for x in range(len(e))])

復号した変数dを表示

>>> d
'Python is very useful!'