#NEWLINE# def des_encript( input , ks , encrypt ) : #NEWLINE# #INDENT# l = input [ 0 ] #NEWLINE# r = input [ 1 ] #NEWLINE# t = U32 ( 0 ) #NEWLINE# u = U32 ( 0 ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 4 , U32 ( 252645135 ) ) #NEWLINE# ( l , r , t ) = PERM_OP ( ( l , r , t ) , 16 , U32 ( 65535 ) ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 2 , U32 ( 858993459 ) ) #NEWLINE# ( l , r , t ) = PERM_OP ( ( l , r , t ) , 8 , U32 ( 16711935 ) ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 1 , U32 ( 1431655765 ) ) #NEWLINE# t = ( ( r << 1 ) | ( r >> 31 ) ) #NEWLINE# r = ( ( l << 1 ) | ( l >> 31 ) ) #NEWLINE# l = t #NEWLINE# s = ks #NEWLINE# if encrypt : #NEWLINE# #INDENT# for i in range ( 0 , 32 , 4 ) : #NEWLINE# #INDENT# ( rtup , u , t , s ) = D_ENCRYPT ( ( l , r , ( i + 0 ) ) , u , t , s ) #NEWLINE# l = rtup [ 0 ] #NEWLINE# r = rtup [ 1 ] #NEWLINE# ( rtup , u , t , s ) = D_ENCRYPT ( ( r , l , ( i + 2 ) ) , u , t , s ) #NEWLINE# r = rtup [ 0 ] #NEWLINE# l = rtup [ 1 ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for i in range ( 30 , 0 , ( - 4 ) ) : #NEWLINE# #INDENT# ( rtup , u , t , s ) = D_ENCRYPT ( ( l , r , ( i - 0 ) ) , u , t , s ) #NEWLINE# l = rtup [ 0 ] #NEWLINE# r = rtup [ 1 ] #NEWLINE# ( rtup , u , t , s ) = D_ENCRYPT ( ( r , l , ( i - 2 ) ) , u , t , s ) #NEWLINE# r = rtup [ 0 ] #NEWLINE# l = rtup [ 1 ] #NEWLINE# #UNINDENT# #UNINDENT# l = ( ( l >> 1 ) | ( l << 31 ) ) #NEWLINE# r = ( ( r >> 1 ) | ( r << 31 ) ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 1 , U32 ( 1431655765 ) ) #NEWLINE# ( l , r , t ) = PERM_OP ( ( l , r , t ) , 8 , U32 ( 16711935 ) ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 2 , U32 ( 858993459 ) ) #NEWLINE# ( l , r , t ) = PERM_OP ( ( l , r , t ) , 16 , U32 ( 65535 ) ) #NEWLINE# ( r , l , t ) = PERM_OP ( ( r , l , t ) , 4 , U32 ( 252645135 ) ) #NEWLINE# output = [ s ] #NEWLINE# output . append ( r ) #NEWLINE# ( l , r , t , u ) = ( U32 ( 0 ) , U32 ( 0 ) , U32 ( 0 ) , U32 ( 0 ) ) #NEWLINE# return output