SHOW:
|
|
- or go back to the newest paste.
1 | - | 'Security: |
1 | + | " |
2 | Security: | |
3 | -> Custom SHA1 | |
4 | -> Offset: 8 | |
5 | -> Calculation Start: 32 | |
6 | -> Calculation Length: See Code | |
7 | ||
8 | Additional: | |
9 | The SHA1 hash is moved to a buffer with the size of 24 bytes. | |
10 | After that the 3 UInt64 parts of the buffer are combined using XOR. | |
11 | - | --- --- --- --- --- --- --- --- --- ---' |
11 | + | " |
12 | ||
13 | byte[] data = File.ReadAllBytes(fileName); | |
14 | ||
15 | using (var r = new Reader(data, Endian.BIG)) { | |
16 | r.Position = 24; | |
17 | int cLen = r.ReadInt32() + r.ReadInt32() - 32; | |
18 | ||
19 | byte[] hash = new byte[24]; | |
20 | using (var sha = new SHA1Managed()) { | |
21 | sha.TransformFinalBlock(data, 32, cLen); | |
22 | Buffer.BlockCopy(sha.Hash, 0, hash, 0, 20); | |
23 | } | |
24 | ||
25 | long checksum = 0; | |
26 | fixed (byte* x = hash) { | |
27 | long* hashP = (long*) x; | |
28 | for (int i = 0; i < 3; ++i, ++hashP) | |
29 | checksum ^= *hashP; | |
30 | } | |
31 | } |