[,] matrix = [, ASCIIEncoding ascii = Generate Virginia Martix ( i = ; i < ; i++ ( j = ; j < ; j++ number = + i + (number > number -= [] bt = [] { ( matrix[i, j] = //加密 button1_Click( key = code = text = List<> keyNum = List<> ( i = ; i < key.Length; i++ str = key.Substring(i, keyNum.Add(()ascii.GetBytes(str)[] - index = - ( i = ; i < .text.Length; i++ (.text.Substring(i, ).ToString() == code += index++ code += matrix[keyNum[index % key.Length], ()ascii.GetBytes(.text.Substring(i, ))[] - .txtCode.Text = //解密 button2_Click( key = code = text = List<> keyNum = List<> ( i = ; i < key.Length; i++ str = key.Substring(i, keyNum.Add(()ascii.GetBytes(str)[] - index = - ( i = ; i < .code.Length; i++ (.code.Substring(i, ).ToString() == text += index++ ( j = ; j < ; j++ (.code.Substring(i, ).ToString() == matrix[keyNum[index % [] bt = [] { ()(j + text += .txtText.Text = }
對於維吉尼亞方陣及運用維吉尼亞方陣的加密與解密,可參考http://baike.baidu.com/view/270838.htm?fromTaglist
畫面結果如下: