Notes on hill

Southwest China's big brother today, i made me a question on age, title name over the hill, then this will have, it is the first chapter.

 

First introduce the hill, Hill is a multi-letter password instead of the password. Hill first plaintext password requirements into a number of packets of the same size (the last to be filled is insufficient packets), each packet is integrally encryption transformation, i.e. Hill encrypted password packet belongs .

The encryption process ~!

First 26 letters of the alphabet are numbered 0-25.

 

 


The following two questions to introduce two master script.

First, the Arnhem Cup tournament a month - Grade Road

After a series of operations, the step is omitted, the most important elements

matrix:

3   1

2   1

Ciphertext:

mttpjbpexfdzcegtdzeanutg

Here posted a master script, c language version.

Link: https: //pan.baidu.com/s/1WjzDJaSHGB2JmA79VLfHQQ

Extraction code: 1f3g

 

 

 

Two, i Spring --over the hill

 

Here is the master script

 1 import numpy
 2 
 3 from sage.all import *
 4 
 5 alphabet = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_{}")
 6 
 7 n = len(alphabet)
 8 
 9 Zn = IntegerModRing(n)
10 
11 secret  = [[54, 53, 28, 20, 54, 15, 12, 7],
12 
13           [32, 14, 24, 5, 63, 12, 50, 52],
14 
15           [63, 59, 40, 18, 55, 33, 17, 3],
16 
17           [63, 34, 5, 4, 56, 10, 53, 16],
18 
19           [35, 43, 45, 53, 12, 42, 35, 37],
20 
21           [20, 59, 42, 10, 46, 56, 12, 61],
22 
23           [26, 39, 27, 59, 44, 54, 23, 56],
24 
25           [32, 31, 56, 47, 31, 2, 29, 41]]
26 
27 secret = matrix(Zn, secret).inverse()
28 
29 ciphertext = "7Nv7}dI9hD9qGmP}CR_5wJDdkj4CKxd45rko1cj51DpHPnNDb__EXDotSRCP8ZCQ"
30 
31 blocks = [ciphertext[i : i + secret.ncols()] for i in range(0, len(ciphertext), secret.ncols())]
32 
33 plaintext = ''
34 
35 for block in blocks:
36 
37     decrypted_block = secret * matrix(Zn, [alphabet.find(c) for c in block]).transpose()
38 
39     plaintext +=  ''.join(alphabet[int(i[0])] for i in decrypted_block)
40 
41  
42 
43 print plaintext
View Code

 

在线运行网站:http://sagecell.sagemath.org/

 

到这里就结束了,脚本都是师傅们的,很惭愧,共勉吧。

over

Guess you like

Origin www.cnblogs.com/BuFFERer/p/12274445.html
Recommended