-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwd.py
54 lines (46 loc) · 1.67 KB
/
pwd.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
50
51
52
53
54
import initSetting
import hashlib
import os
import re
import AES
from PyQt5.QtWidgets import QWidget
passwordStatus = False
if os.path.isfile('setting'):
passwordStatus = True
class passwordCheck(QWidget):
@staticmethod
def SameCheck(first, second):
if first != second:
initSetting.Messaging('Password', '비밀번호가 다릅니다!', 'Warning')
else:
passwordCheck.passwordSecurity(first)
@staticmethod
def passwordSecurity(pw):
if 0 < len(pw) < 10:
initSetting.Messaging('Password', '비밀번호의 길이가 10보다 작습니다!', 'Warning')
elif len(pw) == 0:
initSetting.Messaging('Password', '비밀번호를 입력해주세요.', 'Warning')
elif not re.search(r'\d', pw):
initSetting.Messaging('Password', '숫자가 없습니다.', 'Warning')
elif not re.search(r'[a-z]', pw):
initSetting.Messaging('Password', '문자가 없습니다.', 'Warning')
elif not re.search(r"[~!@#$%^&*]", pw):
initSetting.Messaging('Password', '특수문자가 없습니다.', 'Warning')
else:
passwordCheck.Save(pw)
@staticmethod
def Save(text):
text = passwordCheck.passwordHash(text)
txt = AES.aesEncrypt(text)
f = open("setting", 'w')
f.write(txt)
f.close()
initSetting.Messaging('Password', '비밀번호 저장 완료!', 'Information')
global passwordStatus
passwordStatus = True
@staticmethod
def passwordHash(txt):
enc = hashlib.md5()
enc.update(txt.encode('utf-8'))
hashString = enc.hexdigest()
return hashString