Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings
This repository was archived by the owner on Sep 7, 2025. It is now read-only.
/pythonPublic archive

Commit965d88c

Browse files
shivansh2310abranhe
authored andcommitted
Added implementation of Hill_cipher In python
1 parent14630fe commit965d88c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
importnumpyasnp
2+
s=list(input("Enter a string"))
3+
c=[]
4+
foriinrange(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+
foriinrange(R):
23+
a=[]
24+
forjinrange(C):
25+
a.append(int(input()))
26+
matrix.append(a)
27+
28+
foriinrange(R):
29+
forjinrange(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+
foriinrange(R):
40+
mul[i]=mul[i]%26
41+
42+
print(mul)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp