Cryptography With Python 简明教程

Understanding Vignere Cipher

韦格纳密码加入了恺撒密码算法的微调,用于加密和解密。韦格纳密码与恺撒密码算法的工作方式相似,但有一个主要区别:恺撒密码包括一个字符偏移算法,而韦格纳密码则包括一个有多个字母偏移的密匙。

Vignere Cipher includes a twist with Caesar Cipher algorithm used for encryption and decryption. Vignere Cipher works similar to Caesar Cipher algorithm with only one major distinction: Caesar Cipher includes algorithm for one-character shift, whereas Vignere Cipher includes key with multiple alphabets shift.

Mathematical Equation

对于加密,数学方程式如下:

For encryption the mathematical equation is as follows −

E_{k}\left(M{ {i{}}} \right ) = \left ( M {i}+K_{i}\right)\;\;\;mod\;\;26

E_{k}\left ( M{{i{}}} \right ) = \left ( M{i}+K_{i} \right )\;\;\; mod \;\; 26

对于解密,数学方程式如下:

For decryption the mathematical equation is as follows −

D_{k}\left(C{ {i{}}} \right ) = \left ( C {i}-K_{i}\right)\;\;\;mod\;\;26

D_{k}\left ( C{{i{}}} \right ) = \left ( C{i}-K_{i} \right )\;\;\; mod \;\; 26

韦格纳密码使用多套代换,因此也称为 polyalphabetic cipher 。韦格纳密码将使用字母密匙,而非数字密匙表示法:字母 A 将用于密匙 0,字母 B 将用于密匙 1,依次类推。加密过程前后字母的数字如下所示:

Vignere cipher uses more than one set of substitutions, and hence it is also referred as polyalphabetic cipher. Vignere Cipher will use a letter key instead of a numeric key representation: Letter A will be used for key 0, letter B for key 1 and so on. Numbers of the letters before and after encryption process is shown below −

polyalphabetic cipher

基于韦格纳密匙长度的密钥可能组合数目如下,它给出了韦格纳密码算法的安全性:

The possible combination of number of possible keys based on Vignere key length is given as follows, which gives the result of how secure is Vignere Cipher Algorithm −

Vignere key length

Vignere Tableau

韦格纳密码使用的表如下图所示:

The tableau used for Vignere cipher is as shown below −

vignere tableau