Cryptography With Python 简明教程

One Time Pad Cipher

一次性密文是一种韦格纳密码,它包括以下功能:

One-time pad cipher is a type of Vignere cipher which includes the following features −

  1. It is an unbreakable cipher.

  2. The key is exactly same as the length of message which is encrypted.

  3. The key is made up of random symbols.

  4. As the name suggests, key is used one time only and never used again for any other message to be encrypted.

因此,加密消息对于密码分析员而言容易受到攻击。用于一次性密文的密匙称为 pad ,因为它被印在纸张上。

Due to this, encrypted message will be vulnerable to attack for a cryptanalyst. The key used for a one-time pad cipher is called pad, as it is printed on pads of paper.

Why is it Unbreakable?

密匙无法破解,原因是以下特性:

The key is unbreakable owing to the following features −

  1. The key is as long as the given message.

  2. The key is truly random and specially auto-generated.

  3. Key and plain text calculated as modulo 10/26/2.

  4. Each key should be used once and destroyed by both sender and receiver.

  5. There should be two copies of key: one with the sender and other with the receiver.

Encryption

要加密一封信件,用户需要在纯文本下方书写密钥。纯文本信件放置在顶部,密钥信件放置在左侧。这两个信件之间的横截面为纯文本。如下例中所述:

To encrypt a letter, a user needs to write a key underneath the plaintext. The plaintext letter is placed on the top and the key letter on the left. The cross section achieved between two letters is the plain text. It is described in the example below −

otp

Decryption

要解密一封信件,用户在左侧取得密钥信件,并在该行中查找密文信件。纯文本信件放置在该列的顶部,用户可以在顶部找到密文信件。

To decrypt a letter, user takes the key letter on the left and finds cipher text letter in that row. The plain text letter is placed at the top of the column where the user can find the cipher text letter.