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
|
func recheck(_ keyValue: String) {
var b: [UInt8]=[88, 35, 88, 225, 7, 201, 57, 94, 77, 56, 75, 168, 72, 218, 64, 91, 16, 101, 32, 207, 73, 130, 74, 128, 76, 201, 16, 248, 41, 205, 103, 84, 91, 99, 79, 202, 22, 131, 63, 255, 20, 16]
var k = Array(keyValue.utf8)
var r0, r1, r2, r3: UInt8
for _ in 0...38 {
(k[0], k[1], k[2], k[3]) = (k[1], k[2], k[3], k[0])
}
for i in stride(from: 38, to: -1, by: -1) {
(k[3], k[2], k[1], k[0]) = (k[2], k[1], k[0], k[3])
r0 = b[i + 2] ^ k[2]
r1 = b[i + 3] ^ k[3]
r2 = b[i + 0] ^ ((k[0] + (r0 >> 4)) & 0xff);
r3 = b[i + 1] ^ ((k[1] + (r1 >> 2)) & 0xff);
(b[i], b[i+1], b[i+2], b[i+3]) = (r0, r1, r2, r3)
}
let string = String(decoding: b, as: UTF8.self)
print(string)
}
let key = "345y"
recheck(key)
|