Forwarding Annotated Source: http://www.cnblogs.com/0zcl/p/6106513.html
Objective:
Hill cipher Algorithm I intend to introduce briefly, the encryption matrix I use the textbook 3*3 matrix, only do the encryption, decryption did not do, but I think will be encrypted will be decrypted ~ ~
First, Hill algorithm principle
Hill Password is a multi-letter replacement password, developed by Mathematics Leste Hill in 1929. The cipher algorithm takes m consecutive plaintext letters and replaces them with M-letters, expressed as vectors or matrices (where M=3,c and p are column vectors of length 3, K is the 3*3 matrix):
That is: C=KP (C is ciphertext, p is clear, K is the key matrix)
PS: Cryptographic operation to perform modulo 26 operation
Second, encryption rules
Encryption rules are not difficult, that is, there is a matrix operation (Forget can Gu brother, and line generation about ~)
- Group clear text, every 3 letters a set, the letter Z is not enough (I set, the following programming is also fill Z)
- Perform matrix operations to find ciphertext for each set of letters
Example:
The first 3 letters of the plaintext are expressed as: pay= (0) T
The process of calculating ciphertext: K (0) t= (375 819 486) Tmod 26= (All) t=lns
And so on, can be ciphertext for LNS HDL EWM TRW
Third, programming and thinking
Ideas please see my drawing flowchart, url http://processon.com/diagraming/583aff30e4b086d1e7d3b617
Source
View Code
Test
View Code
Information security -2:python Hill cipher algorithm [original]