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
| import z3 ans_len = 30 y = z3.BitVecs(' '.join("a_%d"%i for i in xrange(ans_len)), 8) x = [0]*ans_len for i in range(ans_len): x[i] = z3.ZeroExt(8,y[i])
s = z3.Solver()
a = [217, 6, 224, 68, 21, 153, 30, 144, 249, 89, 109, 245, 111, 55, 163, 40, 174, 21, 115, 99, 173, 42, 12, 209, 143, 226, 47, 136, 158, 158, 58, 77, 67, 84, 70, 45, 66, 82, 123, 84, 104, 105, 115, 95, 67, 48, 85, 108, 100, 95, 66, 51, 95, 52, 83, 95, 101, 97, 83, 121, 95, 52, 115, 95, 116, 104, 49, 83, 125, 10, 19, 152, 116, 104, 49, 83, 125, 10, 19, 152, 81, 237, 69, 212, 147, 42, 94, 184, 20, 227, 251, 168, 210, 97, 183, 36, 147, 236, 35, 65, 192, 16, 128, 188, 52, 149, 46, 138, 17, 251, 86, 163, 62, 195, 119, 228, 54, 102, 57, 36, 145, 140, 174, 140, 172, 177, 154, 104, 150, 90, 39, 38, 237, 31, 142, 48, 59, 159, 63, 113, 82, 37, 81, 227, 122, 33, 149, 58, 87, 62, 78, 112, 54, 230, 37, 243, 4, 116, 210, 236, 47, 178, 81, 162, 38, 87, 131, 170, 100, 119, 36, 176, 131, 91, 119, 31, 57, 195, 53, 107, 14, 58, 20, 68, 20, 246, 207, 24, 82, 216, 21, 189, 18, 121, 155, 211, 192, 5, 248, 127, 229, 253, 124, 116, 67, 78, 43, 111, 75, 168, 11, 144, 29, 36, 28, 203, 224, 184, 10, 84, 30, 100, 168, 142, 164, 142, 34, 220, 96, 173, 118, 173, 157, 49, 231, 219, 13, 49, 35, 13] final = [208, 113, 230, 50, 15, 58, 9, 46, 248, 161, 182, 82, 222, 205, 101, 114, 82, 159, 79, 185, 244, 114, 118, 193, 52, 53, 238, 247, 218, 80]
for i in range(len(a)/8): m = a[i*8:(i+1)*8] for j in range(8): x[i] = (1<<j)&m[j]^x[i]
for i in range(ans_len): s.add(x[i]==final[i])
if s.check() == z3.sat: m = s.model() print m flag = map(lambda sym: m[sym], y) flag = map(lambda val: chr(int(str(val))), flag) print len(flag) print ''.join(flag)
|