Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 965d88c

Browse filesBrowse files
shivansh2310abranhe
authored andcommitted
Added implementation of Hill_cipher In python
1 parent 14630fe commit 965d88c
Copy full SHA for 965d88c

File tree

1 file changed

+42
-0
lines changed
Filter options

1 file changed

+42
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import numpy as np
2+
s=list(input("Enter a string"))
3+
c=[]
4+
for i in range(len(s)):
5+
c.append(ord(s[i])-65)
6+
7+
arr= np.array(c)
8+
9+
a1=np.transpose(arr)
10+
print(a1)
11+
a1= a1.reshape(3,1)
12+
print(a1.shape)
13+
14+
15+
#key input
16+
print("Enter the key for the encryption")
17+
R = int(input("rows:"))
18+
C = int(input("columns:"))
19+
matrix = []
20+
print("Enter the key:")
21+
22+
for i in range(R):
23+
a =[]
24+
for j in range(C):
25+
a.append(int(input()))
26+
matrix.append(a)
27+
28+
for i in range(R):
29+
for j in range(C):
30+
print(matrix[i][j], end = " ")
31+
matrix = np.array(matrix)
32+
print(matrix.shape)
33+
print(matrix[1][1])
34+
35+
mul=np.matmul(matrix,a1)
36+
mul = np.array(mul)
37+
print(mul.shape)
38+
print(mul)
39+
for i in range(R):
40+
mul[i]=mul[i]%26
41+
42+
print(mul)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.