首页 > 编程语言 >华为机考 HJ87密码强度等级 python

华为机考 HJ87密码强度等级 python

时间:2023-03-14 09:14:08浏览次数:40  
标签:elif python 机考 score4 score c2 print HJ87 check

 

 

 

 

 1 import sys
 2 a=sys.stdin.readline().strip()
 3 def check_num(a):
 4     count=0
 5     for i in a:
 6         if i.isdigit():
 7             count+=1
 8     return count
 9 
10 def check_alpha(a):
11     c,temp,t=0,0,0
12     if a==a.lower() or a==a.upper():
13         return 'A'
14     for i in a:
15         if i.isalpha():
16             t+=1
17         if 'A'<=i<='Z':
18             c+=1
19         if 'a'<=i<='z':
20             temp+=1
21     if t==0:
22         out='N'
23     elif c!=0 and temp!=0:
24         out='B'
25     return out
26 
27 def check_sig(a):
28     c1=0
29     z1,z2=int(0x21),int(0x2F)
30     z3,z4=int(0x3A),int(0x40)
31     z5,z6=int(0x5B),int(0x60)
32     z7,z8=int(0x7B),int(0x7E)
33     for i in a:
34         if z1<=ord(i)<=z2 or z3<=ord(i)<=z4 or z5<=ord(i)<=z6 or z7<=ord(i)<=z8:
35             c1+=1
36     return c1
37 
38 c2=0
39 if len(a)<5:
40     score1=5
41 elif 5<=len(a)<=7:
42     score1=10
43 elif len(a)>7:
44     score1=25
45 if check_num(a)==0:
46     score2=0    
47 elif check_num(a)==1:
48     score2=10
49     c2+=1
50 elif check_num(a)>1:
51     score2=20
52     c2+=1
53 if check_alpha(a)=='N':
54     score3=0
55 elif check_alpha(a)=='A':
56     score3=10
57     c2+=1
58 elif check_alpha(a)=='B':
59     score3=20
60     c2+=2
61 if check_sig(a)==0:
62     score5=0
63     
64 elif check_sig(a)==1:
65     score5=10
66     c2+=1
67 elif check_sig(a)>1:
68     score5=25
69     c2+=1
70 if c2==4:
71     score4=5
72 elif c2==3:
73     score4=3
74 elif c2==2:
75     score4=2
76 else:
77     score4=0
78 score=score1+score2+score3+score4+score5
79 if score>=90:
80     print('VERY_SECURE')
81 elif score>=80:
82     print('SECURE')
83 elif score>=70:
84     print('VERY_STRONG')
85 elif score>=60:
86     print("STRONG")
87 elif score>=50:
88     print('AVERAGE')
89 elif score>=35:
90     print('WEAK')
91 elif score>=0:
92     print('VERY_WEAK')

 

标签:elif,python,机考,score4,score,c2,print,HJ87,check
From: https://www.cnblogs.com/tanyuanqing/p/17213654.html

相关文章