@@ -28,9 +28,10 @@ public static function Hash($string) {
28
28
const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ " ;
29
29
30
30
protected $ SPAMSUM_LENGTH = 64 ;
31
- protected $ MIN_BLOCKSIZE = 3 ;
32
31
protected $ LETTERS = 64 ;
33
32
protected $ BLOCKSIZE = 0 ;
33
+ protected $ MIN_BLOCKSIZE = 3 ;
34
+ protected $ auto_blocksize = true ;
34
35
35
36
protected $ left ;
36
37
protected $ right ;
@@ -47,6 +48,16 @@ public function SetMinBlocksize($s) {
47
48
$ this ->MIN_BLOCKSIZE = $ s ;
48
49
}
49
50
51
+ /**
52
+ * Set the blok size manually, so that it won't be computed from the length of
53
+ * the string
54
+ * @param type $s
55
+ */
56
+ public function SetBlockSize ($ s ) {
57
+ $ this ->BLOCKSIZE = $ s ;
58
+ $ this ->auto_blocksize = false ;
59
+ }
60
+
50
61
/**
51
62
*
52
63
* @param type $string
@@ -65,7 +76,7 @@ public function HashString($string) {
65
76
unset($ in [count ($ in )]);
66
77
67
78
// Guess a a reasonable block size
68
- if ($ this ->BLOCKSIZE == 0 ) {
79
+ if ($ this ->auto_blocksize ) {
69
80
$ this ->BLOCKSIZE = $ this ->MIN_BLOCKSIZE ;
70
81
71
82
while ($ this ->BLOCKSIZE * $ this ->SPAMSUM_LENGTH < $ length ) {
@@ -135,8 +146,9 @@ public function HashString($string) {
135
146
136
147
/* Our blocksize guess may have been way off - repeat if necessary
137
148
*/
138
- if ($ this ->BLOCKSIZE > $ this ->MIN_BLOCKSIZE
139
- && $ j < $ this ->SPAMSUM_LENGTH / 2 ) {
149
+ if ($ this ->auto_blocksize
150
+ && $ this ->BLOCKSIZE > $ this ->MIN_BLOCKSIZE
151
+ && $ j < $ this ->SPAMSUM_LENGTH / 2 ) {
140
152
141
153
$ this ->BLOCKSIZE = $ this ->BLOCKSIZE / 2 ;
142
154
goto again;
0 commit comments