PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
from numpy.linalg import inv
#ENCRYPTION
def affine_encrypt(plain_text,a,B):
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
print("Enter the entries in a single line (separated by space): ")
entries = list(map(int, input().split()))
a = np.array(entries).reshape(R, C)
plain_text = ''.join(e for e in plain_text if e.isalnum()).upper()
if len(plain_text) % 2 == 0:
B=np.arange(1,len(plain_text)//2). reshape(2,-1)
if len(plain_text) % 2 != 0:
B=np.arange(1,(len(plain_text)+1)//2). reshape(2,-1)
if len(plain_text) % 2 != 0:
plain_text += 'X'
plain_num = np.array([ord(c) - ord('A') for c in plain_text])
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run