-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecsm2 (5).py
49 lines (38 loc) · 908 Bytes
/
ecsm2 (5).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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
You have to use fundamentals of Python taught in module 2
1.Read the input from command line –Reference ID
2.Check for validity –
it should be 12 digits and allows on number and alphabet
For windows
try
py -m pip install maskpass
py -m pip install rsa
For linux
try
pip install maskpass
pip install rsa
then run this code
'''
import maskpass
import rsa
#add 0value to strings
publicKey, privateKey = rsa.newkeys(512)
l, d = 0, 0
str = maskpass.askpass('Reference ID: ')
lc="abcdefghijklmnopqrstuvwxyz"
digits="0123456789"
if (len(str)==12 ):
for i in str:
# counting lowercase alphabets
if (i in lc):
l+=1
# counting digits
if (i in digits):
d+=1
if (l>=1 and d>=1 and l+d==len(str)):
eid = rsa.encrypt(str.encode(),
publicKey)
print("Valid Reference ID")
print("Encoded RID",eid)
else:
print("Invalid Reference ID")