08:vigenère密碼_密碼技術:Vigenére密碼,Playfair密碼,Hill密碼

08:vigenère密碼

1)Vigenére密碼 (1) Vigenére Cipher)

This technique is an example of Polyalphabetic Substitution technique which uses 26 Caesar ciphers make up the mono-alphabetic substitution rules which follow a count shifting mechanism from 0 to 25. That is, for each plain-text character we have a corresponding substitution known as a key letter.

該技術是使用26個凱撒密碼彌補隨后的計數移動機構從0到25。也就是說,對于我們的相應取代已知為每個純文本字符的單字母替換規則多碼替代技術的一個例子關鍵信

To understand this technique we need to take a look on this Vigenére tableau.

要了解此技術,我們需要看一下Vigenére表格

Vigenére tableau

The logic for this technique is simple, say for a key letter 't' and plain-text letter 'h', the corresponding cipher-text letter is at the intersection of row titled 't' and column titled 'h' thus for this case we get a ciphertext that would be 'A' based on above table.

這種技術的邏輯很簡單,例如對于一個關鍵字母“ t”和純文本字母“ h” ,相應的密文字母位于標題為“ t”的行與標題為“ h”的列的交點處。情況下,根據上表,我們將得到一個密文“ A”

It is clear that for encrypting a plain-text message we must need a key whose length is equal to the size of the plain-text message usually a repeating key is used.

顯然,為了加密純文本消息,我們需要一個長度等于純文本消息大小的密鑰,通常使用重復密鑰。

2)Playfair密碼 (2) Playfair Cipher)

Playfair cipher (aka Playfair square) is a cryptography technique used for manual encryption, it was introduced by Charles Wheatstone in 1854 but it was popularized by Lord Playfair hence his name used.

Playfair密碼(又名Playfair平方)是一種用于手動加密的加密技術,由Charles Wheatstone于1854年提出,但后來被Playfair勛爵推廣,因此使用了他的名字。

The Playfair cipher was used in world war I by the British army and in World war II it was used by Australians. It was because the Playfair cipher is quite fast to use and does not demand any special equipment.

Playfair密碼在第一次世界大戰中被英國軍隊使用,在第二次世界大戰中被澳大利亞人使用。 這是因為Playfair密碼使用起來非常快,并且不需要任何特殊設備。

Playfair technique has 2 major steps:

Playfair技術有兩個主要步驟:

Playfair Cipher

Step 1: Creation and Population of matrix

步驟1:矩陣的創建和填充

This technique uses a 5 x 5 matrix which stores a keyword (or phrase) that becomes the key for encryption or decryption. This involves some set of fixed rule, those are:

該技術使用5 x 5矩陣 ,該矩陣存儲一個關鍵字(或短語),該關鍵字成為加密或解密的密鑰。 這涉及到一些固定規則,它們是:

  1. Fill the keyword in the matrix row-wise from left to right, top to down.

    從左到右,從上到下按行在矩陣中填充關鍵字。

  2. Remove all repeated letters.

    刪除所有重復的字母。

  3. Enter the remaining spaces in the matrix with the rest of the English alphabets (A-Z) that were not a part of our keyword. In this process, combine I and J in the same cell of the table; in other words, if I and J is a part of the keyword disregard both I and J while filling the remaining slots.

    在矩陣中輸入剩余的空格以及不屬于我們關鍵字的其余英文字母( AZ )。 在此過程中,將IJ合并到表的同一單元格中; 換句話說,如果IJ是關鍵字的一部分,則在填充其余插槽時,請同時忽略IJ。

Example:

例:

Let's take our keyword as 'INCLUDEHELP IS AWESOME'. Then 5 x 5 matrix will look as:

讓我們將關鍵字設為“ INCLUDEHELP IS AWESOME” 。 然后5 x 5矩陣將如下所示:

Playfair Cipher Example Image 1

Step 2: Encryption

步驟2:加密

This process consist of the following process:

此過程包括以下過程:

  1. The plain-text we want to encrypt need to broke down into a pair of alphabets. For example, if our message is "MY NAME IS POGO", it will become "MY NA ME IS PO GO".

    我們要加密的純文本需要分解為一對字母。 例如,如果我們的消息是“ MY NAME IS POGO” ,它將變成“ MY NA ME IS PO GO”

  2. If both alphabets are the same (or only left), add an X after the first alphabet in a pair. Encrypt the new pair (after adding X) then continue.

    如果兩個字母相同(或僅向左),則在成對的第一個字母之后添加X。 加密新對(添加X之后 ),然后繼續。

    1. If pair appears in the same row of the matrix, replace them with a letter at its right, if it's at the right end of the row then wrapping around the left side of the row.
  3. If pair appears in the same column of the matrix, replace them with the alphabet below them. If it's on the bottom then wrapping around the top of the row.

    如果對出現在矩陣的同一列中,請用其下面的字母替換它們。 如果它在底部,則環繞該行的頂部。

  4. If the pairis not in the same row or column, replace them with the alphabets in the same row respectively, but at the other pair of cornersof the rectangle defined by the original pair. The order is quite significant here. The first encrypt alphabet of the pair is the one that is present on the same row as the first plaintext alphabet.

    如果該對不在同一行或同一列中,則分別用同一行中的字母代替它們,而應替換為原始對定義的矩形的另一對角。 這里的順序非常重要。 該對中的第一個加密字母是與第一個明文字母在同一行上的字母。

Explanation:

說明:

"MY NA ME IS PO GO"

“我不喜歡我”

So we start with MY now in the above matrix it was not in the same row or column then rule 5 will apply.

因此,我們從上面的矩陣中的MY開始,因為它不在同一行或同一列中,所以將應用規則5。

Playfair Cipher Example Image 2

Now we replace 'MY' with the diagonals that are 'KZ'.

現在我們將對角線KZ替換為MY

Let's move to 'NA' again they are not in the same row or column, rule 5 will apply.

讓我們再次移至“ NA”(它們不在同一行或同一列中),將應用規則5。

Playfair Cipher Example Image 3

Now, 'NA' will be replaced with 'UE'.

現在, “ NA”將被替換為“ UE”

Similarly, "MY NA ME IS PO GO" will become "KZ UE FA LO DS BS".

類似地, “ MY NA ME IS PO GO”將變為“ KZ UE FA LO DS BS”

For the decryptionprocess, we will just follow the exact opposite steps.

對于解密過程,我們將遵循完全相反的步驟。

3)希爾密碼 (3) Hill Cipher)

The Hill cipher is based on polygraphic substitution that is it works on multiple letters at the same time, introduced by Lester Hill in 1929. This method related to the matrix theory of mathematics, specifically how to compute the inverse of a matrix.

希爾密碼是基于多重圖形替換的,它同時處理多個字母,這是萊斯特·希爾(Lester Hill)在1929年提出的。這種方法與數學的矩陣理論有關,特別是如何計算矩陣的逆。

Let's see how it works:

讓我們看看它是如何工作的:

  1. Every Letter of plain-text will be represented by a number, so that A=0, B=1,...,Z=25.

    每個純文本字母將由一個數字表示,因此A = 0,B = 1,...,Z = 25

  2. We will make a matrix of the plain-text message using the above knowledge.

    我們將使用以上知識來構成純文本消息的矩陣。

    For example,

    例如,

    'CAT', so C=2, A=0, T=19. Thus our matrix lookslike:

    'CAT' ,因此C = 2,A = 0,T = 19 。 因此我們的矩陣看起來像:

    Hill Cipher Example Image 1
  3. Now, we multiply our matrix with randomly chosen keys. The size of the key must be n x n where n is a number of rows of our plain-text matrix.

    現在,我們將矩陣與隨機選擇的鍵相乘。 鍵的大小必須為nxn ,其中n是純文本矩陣的行數。

    For example:

    例如:

    Hill Cipher Example Image 2
  4. Now multiply the above matrices,

    現在將上述矩陣相乘,

    Hill Cipher Example Image 3
  5. Now we will calculate a mod 26 value of the above matrix, that is remainder after dividing 26.

    現在我們將計算上述矩陣的mod 26值,即除以26后的余數。

    Hill Cipher Example Image 4
  6. Translate back number to alphabets, 5=F, 8=I, 13=N. Therefore, our cipher-text is "FIN".

    將數字轉換回字母,即5 = F8 = I13 = N。 因此,我們的密文為“ FIN”

  7. For Decryption, take the cipher-text matrix and multiply it with the inverse of our original key matrix:

    對于解密,請采用密文矩陣并將其與原始密鑰矩陣的逆矩陣相乘:

    Hill Cipher Example Image 5

翻譯自: https://www.includehelp.com/cryptography/cryptographic-techniques-vigenére-cipher-playfair-cipher-hill-cipher.aspx

08:vigenère密碼

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/376952.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/376952.shtml
英文地址,請注明出處:http://en.pswp.cn/news/376952.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Redis的RDB文件與AOF文件

本筆記參考《Redis設計與實現》 P118 ~ P150 RDB文件 1、RDB文件用于保存和還原Redis服務器所有數據庫中的所有鍵值對數據 2、SAVE命令由服務器進程直接執行保存操作,該命令會阻塞服務器 3、BGSAVE命令由子進程執行保存操作,不會阻塞服務器 注意此時服…

eclipse擴容

eclipse擴容 -vmD:/jdk-6u17-windows-i586/jdk1.6.0_17/bin/javaw.exe-startupplugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar-nlen_US--launcher.libraryplugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20120913-144807-productorg.eclipse…

node oauth2驗證_如何設置和使用護照OAuth Facebook身份驗證(第2部分)| Node.js

node oauth2驗證In my last article (How to set up and use passport OAuth Facebook Authentication (Section 1) | Node.js), we looked at another form of authentication called the OAuth authentication which involves sign in or signup using social media. 在我的上…

Python and Microsoft Word

國外網站看到的文章:Accessing Microsoft Word with Python follows the same syntax that we used for Excel. Let’s take a quick look at how to access Word.from time import sleep import win32com.client as win32RANGE range(3, 8)def word():word win32…

東哥讀書小記 之 《一個廣告人的自白》

掰著指頭一算,端午假期確實完成不少事情,過的太尼瑪充實鳥:去健身房2小時,且老夫的平板支撐終于能堅持超過1分鐘,普大喜奔有木有;給合租的室友買蛋糕過了個生日;去 去哪兒 參加W3ctech的技術交流…

Redis的文件事件與時間事件處理

目錄文件事件處理事件類型客戶端和服務端的通信過程時間事件處理執行器執行周期性事件作用事件的調度與執行文件事件處理 Redis基于Reactor模式開發了文件事件處理器。文件事件處理器以單線程方式運行,通過IO多路復用程序監聽多個套接字,實現了高性能網…

fisher-yates_使用Fisher-Yates隨機播放算法以O(n)時間隨機播放給定數組

fisher-yatesExample: 例: Say the input array is [1, 2 3, 4, 5 6, 7]After reshuffling it can be anything like[4, 3, 7, 2, 1, 5, 1]Our goal is that the reshuffling should be as random as possible. 我們的目標是,改組應盡可能地隨機。 The…

[分享]一些在 WPF/Silverlight 中應用 MVVM 模式時可能會有點用途的代碼

想來這個博客也已經有很久沒更新過了,新年新氣象,現在就開始寫新內容吧。 最初的起因 在最近的幾個月中我做的開發總是要跟 XAML 打交道,也就是 WPF 啊,Silverlight 啊,WF 啊這些。 在進行 WPF 和 Silverlight 開發的…

手機調用系統的拍照和裁剪功能,假設界面有輸入框EditText,在一些手機會出現點擊EditText會彈出輸入法,卻不能輸入的情況。...

1、拍照裁剪后 點擊EditText會彈出輸入法,卻不能輸入。可是點擊點一EdtiText就能夠輸入了,所以我就寫了一個看不見的EdtiText,切換焦點,這樣就攻克了這個奇怪的這問題,應該是android內部的問題。 這是網絡一個牛人留下…

Redis一個命令請求從發送到完成的步驟以及初始化服務器步驟

一個命令請求從發送到完成的步驟 如下: 1、客戶端將命令請求發送給服務器 當用戶在客戶端中鍵入一個命令請求時,客戶端會將這個命令請求轉換成協議格式,然后通過連接到服務器的套接字,將協議格式的命令請求發送給服務器。 2、服…

c打印行號和函數_使用C中的函數名稱,行號從任何函數打印錯誤消息

c打印行號和函數Sometimes, it is necessary to print some message on logic failure or anytime with the function name and line number, so that program can be debugged and fixed the issue. 有時,有必要在邏輯故障時或在任何時候使用功能名稱和行??號打印…

Linux SPI框架

水平有限,描述不當之處還請指出,轉載請注明出處http://blog.csdn.net/vanbreaker/article/details/7733476 Linux的SPI子系統采用主機驅動和外設驅動分離的思想,首先主機SPI控制器是一種平臺設備,因此它以platform的方式注冊進內…

dbms標識符無效_DBMS中的嵌套查詢,相關的嵌套查詢和集合比較運算符

dbms標識符無效嵌套查詢 (Nested Queries) A query embedded in a query. This type of relation is termed as Nested Query and the Embedded Query is termed as a subquery. 查詢中嵌入的查詢。 這種類型的關系稱為嵌套查詢,而嵌入式查詢稱為子查詢。 For exam…

重構——解決過長參數列表(long parameter list)

目錄1、Replace Param with Query2、Preserve Whole Object3、Introduce Param Object4、Remove Flag Argument5、Combine Functions into ClassReference當我們需要在超長函數中提煉子函數時,如果函數內有大量的參數和臨時變量,這將會對函數的提煉形成很…

C# 點點滴滴: out和ref

用c#很長一段時間了,不過基本是啥都不會,當C用的,作為寫單片機的,還是真心覺得C比較親切,呵呵。 不過總是要進步啊,慢慢積累唄,這次是寫一個CAN的上位機模板出來,以后的項目就要徹底…

css控制圖片最寬 最高值

.content img{width:expression_r(this.width > 500 && this.height < this.width ? 500:true);max-width:500px;height:expression_r(this.height >500 ? 500:true);max-height:500px; }轉載于:https://www.cnblogs.com/panlin/archive/2013/01/06/2848017…

踩踩踩

http://china.findlaw.cn/laodongfa/ctjg/cy/cybc/ 二、合法裁員經濟補償標準的計算 按照《勞動合同法》第四十七條規定&#xff0c;經濟補償按勞動者在本單位工作的年限&#xff0c;每滿一年支付一個月工資的標準向勞動者支付。六個月以上不滿一年的&#xff0c;按一年計算;不…

c# 字節十六進制轉十進制_用C中的十進制,八進制和十六進制數字初始化字節數組...

c# 字節十六進制轉十進制C中的字節數組 (byte array in C) In C programming language, an unsigned char type can be used to declare byte array in C programming language. An unsigned char can contain a value from 0 to 255, which is the value of a byte. 在C編程語…

從uptime、stress、mpstat、pidstat觀察CPU密集型、IO密集型、進程密集型切換的系統性能

uptime dyydyy-Lenovo-ThinkBook-14-IIL:~$ uptime10:27:10 up 7 min, 1 user, load average: 1.32, 0.99, 0.49結果分別對應&#xff1a;當前時間、系統運行時間、當前用戶數目、過去 1 分鐘、5 分鐘、15 分鐘的平均負載(Load Average) 平均負載是指單位時間內&#xff0c…

解析和創建xml

http://www.cnblogs.com/Li-Cheng/p/3610474.html 轉載于:https://www.cnblogs.com/mxw272618/p/3769900.html