このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
crypt:xor [2012/02/18 04:22] kikuzou |
crypt:xor [2012/02/18 05:08] kikuzou |
||
---|---|---|---|
行 2: | 行 2: | ||
====== XOR ====== | ====== XOR ====== | ||
+ | * 排他的論理和(XOR)を使用した暗号 | ||
===== xortools ===== | ===== xortools ===== | ||
行 15: | 行 16: | ||
out_buf.write(single_byte_xor(in_buf, | out_buf.write(single_byte_xor(in_buf, | ||
out_buf.close() | out_buf.close() | ||
+ | </ | ||
+ | |||
+ | === Sample Script === | ||
+ | * 指定したファイルを key 0-255 でXOR (256個のファイルを作成) ((素人が作成したので、もっときれいにして下さいw)) | ||
+ | |||
+ | <code python xor-single.py> | ||
+ | # | ||
+ | # -*- coding: UTF-8 -*- | ||
+ | |||
+ | import sys | ||
+ | from xortools import single_byte_xor | ||
+ | |||
+ | key = 0 | ||
+ | argvs = sys.argv | ||
+ | |||
+ | in_buf = open(argvs[1], | ||
+ | |||
+ | while key < 256: | ||
+ | hkey = hex(key) | ||
+ | output = str(argvs[1]) + ' | ||
+ | out_buf = open(output, | ||
+ | out_buf.write(single_byte_xor(in_buf, | ||
+ | out_buf.close() | ||
+ | key += 1 | ||
</ | </ | ||