| 1521 | |
| 1522 | == Pascal == |
| 1523 | {{{ |
| 1524 | procedure ComputeHash(const Stream : TStream; |
| 1525 | out Size : qword; |
| 1526 | out Hash : string); |
| 1527 | var |
| 1528 | hashQ : qword; |
| 1529 | fsize : qword; |
| 1530 | i : integer; |
| 1531 | read : integer; |
| 1532 | s : array[0..7] of char; |
| 1533 | tmp : qword absolute s; |
| 1534 | begin |
| 1535 | Stream.Seek(0, soFromBeginning); |
| 1536 | Size := Stream.Size; |
| 1537 | hashQ := size;; |
| 1538 | |
| 1539 | i := 0; |
| 1540 | read := 1; |
| 1541 | while ((i < 8192) and (read > 0)) do begin |
| 1542 | read := Stream.Read(s, sizeof(s)); |
| 1543 | if read > 0 then begin |
| 1544 | hashQ := hashQ + tmp; |
| 1545 | end; |
| 1546 | i := i + 1; |
| 1547 | end; |
| 1548 | |
| 1549 | Stream.Seek(-65536, soFromEnd); |
| 1550 | |
| 1551 | i := 0; |
| 1552 | read := 1; |
| 1553 | while ((i < 8192) and (read > 0)) do begin |
| 1554 | read := Stream.Read(s, sizeof(s)); |
| 1555 | if read > 0 then begin |
| 1556 | hashQ := hashQ + tmp; |
| 1557 | end; |
| 1558 | i := i + 1; |
| 1559 | end; |
| 1560 | |
| 1561 | Hash := lowercase(Format('%.16x',[hashQ])); |
| 1562 | end; |
| 1563 | }}} |