Home

AES加密

2018/08/21

AES加密

1、AES加密原理简单介绍

AES加密过程是在一个4×4的字节矩阵上运作,这个矩阵又称为“状态(state)”,其初值就是一个明文区块(矩阵中一个元素大小就是明文区块中的一个Byte)。(Rijndael加密法因支持更大的区块,其矩阵行数可视情况增加)加密时,各轮AES加密循环(除最后一轮外)均包含4个步骤:

AddRoundKey — 矩阵中的每一个字节都与该次轮秘钥(round key)做XOR运算;每个子密钥由密钥生成方案产生。

SubBytes — 通过非线性的替换函数,用查找表的方式把每个字节替换成对应的字节。

ShiftRows — 将矩阵中的每个横列进行循环式移位。

MixColumns — 为了充分混合矩阵中各个直行的操作。这个步骤使用线性转换来混合每列的四个字节。

最后一个加密循环中省略MixColumns步骤,而以另一个AddRoundKey取代。

详细过程如下图:

image

2、程序各模块详细设计

2.1 显示模块

image

2.2 代码模块

image

3、程序代码

3.1 decode.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import 密钥扩展
#逆行移位
def InvShiftRows(input1):
out = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
out[i][j+i-4] = input1[i][j]
return out
#逆字节替代
def InvSubBytes(input1):
out = [['*'for i in range(4)]for i in range(4)]
map_ = [0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]
for i in range(4):
for j in range(4):
out[i][j] = map_[input1[i][j]]
return out
#逆列混合
def InvMixColumns(inputt):
col = [[0x0E,0x0B,0x0D,0x09],[0x09,0x0E,0x0B,0x0D],[0x0D,0x09,0x0E,0x0B],[0x0B,0x0D,0x09,0x0E]]
out = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
out[i][j]=Mult(inputt[0][j],col[i][0])^Mult(inputt[1][j],col[i][1])^Mult(inputt[2][j],col[i][2])^Mult(inputt[3][j],col[i][3])
return out
#点乘
def Mult(a,b):
temp = ['']*8
temp[0]=int(a)
for i in range(7):
if temp[i]<128:
temp[i+1] = temp[i]<<1 #若小于0b10000000则直接右移
else:
temp[i+1] = ((temp[i]<<1)-0x100)^0x1B
mult = 0x00
for i in range(8):
mult ^= (b>>i&1)*temp[i]
return mult
#轮密钥加
def AddRoundKey(input_,key):
temp = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
temp[i][j] = key[i][j]^input_[i][j]
return temp
#规范输出格式(列表-->字符串)
def PrintOut(Input):
temp = []
for j in range(4):
for i in range(4):
a = hex(Input[i][j])[2:]
if len(a)<2:
a = '0'+a
temp.append(a)
out = ''.join(map(str,temp))
return out
#解密过程
def decode(input1):
#test = [[0x39,0x02,0xdc,0x19],[0x25,0xdc,0x11,0x6a],[0x84,0x09,0x85,0x0b],[0x1d,0xfb,0x97,0x32]]
key = [[0x2b,0x28,0xab,0x09],[0x7e,0xae,0xf7,0xcf],[0x15,0xd2,0x15,0x4f],[0x16,0xa6,0x88,0x3c]]
#key = [[15, 21, 113, 201], [71, 217, 232, 89], [12, 183, 173, 214], [175, 127, 103, 152]]
test = input1
temp = []
for j in range(4):
temp.append(key[j])
for i in range(10):
n = i
key = 密钥扩展.KeySchedule(key,n)
for j in range(4):
temp.append(key[j])
#print(temp)
out1 = AddRoundKey(test,key[-4:]) #第一次轮密钥加
for i in range(9): #循环九轮(逆行移位-->逆字节替代-->轮密钥加-->逆列混合)
out2 = InvSubBytes(InvShiftRows(out1))
k = temp[(-4)*(i+2):(-4)*(i+2)+4] #i从0开始,i=0时,(-4)*(i+2)=-8
out1 = InvMixColumns(AddRoundKey(out2,k))
out = InvSubBytes(InvShiftRows(out1)) #第十轮(逆行移位-->逆字节替代)
out1 = AddRoundKey(out,temp[0:4]) #最后一次轮密钥加
print("明文为:"+PrintOut(out1))
#密钥可变,复制上面函数,增加一个变量Key
def decodeWithKey(input1,Key):
key = Key
test = input1
temp = []
for j in range(4):
temp.append(key[j])
for i in range(10):
n = i
key = 密钥扩展.KeySchedule(key,n)
for j in range(4):
temp.append(key[j])
out1 = AddRoundKey(test,key[-4:]) #第一次轮密钥加
for i in range(9): #循环九轮(逆行移位-->逆字节替代-->轮密钥加-->逆列混合)
out2 = InvSubBytes(InvShiftRows(out1))
k = temp[(-4)*(i+2):(-4)*(i+2)+4] #i从0开始,i=0时,(-4)*(i+2)=-8
out1 = InvMixColumns(AddRoundKey(out2,k))
out = InvSubBytes(InvShiftRows(out1)) #第十轮(逆行移位-->逆字节替代)
out1 = AddRoundKey(out,temp[0:4]) #最后一次轮密钥加
print("明文为:"+PrintOut(out1))
#从文档读取明文
def ReadFile():
file = open('test.txt','r')
temp = []
a = file.readlines()
for i in a:
b = i.split( )
if b:
for j in b:
temp.append(j[4:])
else:
return("文件为空!")
input1 = []
for i in range(int(len(temp)/2)): #len(a)/2为浮点数
for j in range(16):
b = '0x'+temp[i*2+1][j*2:j*2+2]
input1.append(int(b,16))
input2 = [['*'for n in range(4)]for n in range(4)]
x = 0
for n in range(4): #一维数组转二维数组
for m in range(4):
input2[m][n] = input1[x]
x = x+1
input1 = []
print("密文为:"+PrintOut(input2))
decode(input2)
print('--------------------------------------------------------------------------------------')
return("读取完毕!")
def Trans(Input):
temp = Input
input1 = []
for i in range(16): #len(a)/2为浮点数
b = '0x'+temp[i*2:i*2+2]
input1.append(int(b,16))
input2 = [['*'for n in range(4)]for n in range(4)]
x = 0
for n in range(4): #一维数组转二维数组
for m in range(4):
input2[m][n] = input1[x]
x = x+1
return(input2)
'''
一维数组-->二维数组
for n in range(4): #一维数组转二维数组
input2.append(input1[n*4:n*4+4])
'''

3.2 encode.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import 密钥扩展
#字节替代
def SubBytes(inputt):
out_ = [['*'for i in range(4)]for i in range(4)]
map_ = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16]
for i in range(4):
for j in range(4):
out_[i][j] =map_[inputt[i][j]]
return out_
#行移位
def ShiftRows(inputt):
out = [['*'for i in range(4)]for i in range(4)] # 创建一个空的二维数组用:
# temp=[['*'for i in range(n)]for i in range(m)]
# !不使用:
# temp=[['*']*n]*m
for i in range(4):
for j in range(4):
out[i][j-i] = inputt[i][j]
return out
#列混合
def MixColumns(inputt):
col = [[0x02,0x03,0x01,0x01],[0x01,0x02,0x03,0x01],[0x01,0x01,0x02,0x03],[0x03,0x01,0x01,0x02]]
out = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
out[i][j]=Mult(inputt[0][j],col[i][0])^Mult(inputt[1][j],col[i][1])^Mult(inputt[2][j],col[i][2])^Mult(inputt[3][j],col[i][3])
return out
#点乘
def Mult(a,b):
temp = ['']*8
temp[0]=int(a)
for i in range(7):
if temp[i]<128:
temp[i+1] = temp[i]<<1 #若小于0b10000000则直接右移
else:
temp[i+1] = ((temp[i]<<1)-0x100)^0x1B
mult = 0x00
for i in range(8):
mult ^= (b>>i&1)*temp[i]
return mult
#轮密钥加
def AddRoundKey(input_,key):
temp = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
temp[i][j] = key[i][j]^input_[i][j]
return temp
#规范输出格式
def PrentOut(input_):
temp = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
temp[i][j] = hex(input_[i][j])
return temp
#加密过程
def encode(test):
input1 = test
key = [[0x2b,0x28,0xab,0x09],[0x7e,0xae,0xf7,0xcf],[0x15,0xd2,0x15,0x4f],[0x16,0xa6,0x88,0x3c]]
out1 = AddRoundKey(input1,key)
for i in range(9):
n = i
out2 = MixColumns(ShiftRows(SubBytes(out1)))
key = 密钥扩展.KeySchedule(key,n)
out1 = AddRoundKey(out2,key)
out2 = ShiftRows(SubBytes(out1))
key = 密钥扩展.KeySchedule(key,9)
out1 = AddRoundKey(out2,key)
print('--------------------------------------------------------------------------------------')
return out1

3.3 密钥扩展.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
#主函数
def KeySchedule(input1,num):
Input = input1
n = num
k3 = ['*'for i in range(4)]
for i in range(4):
k3[i] = Input[i][3]
out = Output(Input,k3,n)
return out
#输出
def Output(Input,k3,num):
n = num
Tk3 = Rcons45(SubBytes45(ShiftRows45(k3)),n)
out = Mod45(Input,Tk3)
#将输出结果转为十六进制
trans = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
trans[i][j] = hex(out[i][j])
return out
#左循环1字节
def ShiftRows45(k3):
out = ['*'for i in range(4)]
for j in range(4):
if(j==3):
out[3] = k3[0]
else:
out[j] = k3[j+1]
return out
#s盒替换
def SubBytes45(k3):
out = ['*'for i in range(4)]
Map = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16]
for j in range(4):
out[j] = Map[k3[j]]
return out
#根据rocn常量表查表
def Rcons45(k3,n):
Rcon = [0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36]
k3[0] = Rcon[n]^k3[0]
return k3
#异或
def Mod45(Input,k3):
out = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
out[i][0] = Input[i][0]^k3[i]
for j in range(3):
for i in range(4):
out[i][j+1] = Input[i][j+1]^out[i][j]
return out

3.4 测试用例.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
import random
import encode
import decode
#随机生成明文加密并保存(一次)
def TestFun():
input1 = [['*'for i in range(4)]for i in range(4)]
for i in range(4):
for j in range(4):
input1[i][j] = random.randint(0,255)
out = encode.encode(input1)
a = PrintOut(input1)
b = PrintOut(out)
print('明文为:'+PrintOut(input1))
print('密文为:'+PrintOut(out))
print('--------------------------------------------------------------------------------------')
file = open('test.txt','a')
file.write('明文为:%s \t 密文为:%s\n'%(a,b))
#规范输出格式(列表-->字符串)
def PrintOut(Input):
temp = []
for j in range(4):
for i in range(4):
a = hex(Input[i][j])[2:]
if len(a)<2:
a = '0'+a
temp.append(a)
out = ''.join(map(str,temp))
return out
#生成明文并加密功能
def encodeFun():
print('How much times do you want to do?')
n = int(input())
for i in range(n):
TestFun()
#读取密文并解密功能
def decodeFun():
a = decode.ReadFile()
print(a)

3.5 GUI测试~(主程序).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
55
import easygui as g
import sys
import 测试用例
import decode
g.msgbox("这是一个AES加解密程序!",title = "AES加解密")
while 1:
msg ="请问你想要完成怎样的功能?"
title = "AES加解密"
choices = ["加密(随机生成明文)", "解密(读取文档)", "查看文档内容", "标准测试(可自定义)", "退出程序~"]
choice = g.choicebox(msg, title, choices)
if choice == None: #关掉选择窗口或者cancel时退出
sys.exit(0)
if choice == "加密(随机生成明文)":
num = g.integerbox("请输入想要生成的明文个数:",title = choice,lowerbound = 1,upperbound = 10)
if num == None:
sys.exit(0)
for i in range(int(num)):
测试用例.TestFun()
print("加密完毕")
if choice == "查看文档内容":
file = open('test.txt','r')
text = file.readlines()
g.textbox(msg = "当前文档内容为",title = choice ,text = text)
if choice == "解密(读取文档)":
print("开始读取文档...")
a = decode.ReadFile()
print(a)
if choice == "退出程序~":
sys.exit(0)
if choice == "标准测试(可自定义)":
fieldNames = ["密文","密钥"]
fieldValues = ["3925841d02dc09fbdc118597196a0b32","2b7e151628aed2a6abf7158809cf4f3c"]
#3243f6a8885a308d313198a2e0370734
fieldValues = g.multenterbox( "加密测试(默认值为标准fips-197,可修改)", "加密测试",fieldNames,fieldValues)
Input = decode.Trans(fieldValues[0])
Key = decode.Trans(fieldValues[1])
decode.decodeWithKey(Input,Key)
msg = "需要返回功能选择页面吗?"
title = "返回or退出"
if g.ccbox(msg, title):
pass
else:
sys.exit(0)