你不能。
考虑这个简单的例子(python):
def xor(s1, s2): return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1, s2))
key = '\x07\x07\x04\x16\x00\x1b\x12N\x17\x1a\x0eHO\x14T\x03\x10\x17R\n\x16V\x04\n\x06\x00\r\x1e'
message = 'this is such a secret message'
ciphertext = xor(message, key)
这是一个简单的异或密码,可用于例如在一次性垫。显然没有错,但如果你打印ciphertext,你会得到:'some random output obviously'。
秘密消息已正确加密,但输出看起来根本没有加密。
我通过 xoring 消息和示例输出选择了密钥 ;-) 但这样的密钥基本上是随机的,可以是任何随机数生成器的结果。
您永远无法仅通过查看位来判断数据是否已加密、编码、压缩、屏蔽或其他,因为即使这些位看起来像未加密的内容。这也是不能对 OTP 进行暴力破解的原因,因为您永远无法判断暴力破解的明文是否是正确的明文:http://en.wikipedia.org/wiki/One-time_pad#Attempt_at_cryptanalysis
自己试试吧:
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def xor(s1, s2): return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1, s2))
...
>>> key = '\x07\x07\x04\x16\x00\x1b\x12N\x17\x1a\x0eHO\x14T\x03\x10\x17R\n\x16V\x04\n\x06\x00\r\x1e'
>>> message = 'this is such a secret message'
>>> ciphertext = xor(message, key)
>>> print ciphertext
some random output obviously