@@ -28,9 +28,10 @@ public static function Hash($string) {
2828 const B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ " ;
2929
3030 protected $ SPAMSUM_LENGTH = 64 ;
31- protected $ MIN_BLOCKSIZE = 3 ;
3231 protected $ LETTERS = 64 ;
3332 protected $ BLOCKSIZE = 0 ;
33+ protected $ MIN_BLOCKSIZE = 3 ;
34+ protected $ auto_blocksize = true ;
3435
3536 protected $ left ;
3637 protected $ right ;
@@ -47,6 +48,16 @@ public function SetMinBlocksize($s) {
4748 $ this ->MIN_BLOCKSIZE = $ s ;
4849 }
4950
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+
5061 /**
5162 *
5263 * @param type $string
@@ -65,7 +76,7 @@ public function HashString($string) {
6576 unset($ in [count ($ in )]);
6677
6778 // Guess a a reasonable block size
68- if ($ this ->BLOCKSIZE == 0 ) {
79+ if ($ this ->auto_blocksize ) {
6980 $ this ->BLOCKSIZE = $ this ->MIN_BLOCKSIZE ;
7081
7182 while ($ this ->BLOCKSIZE * $ this ->SPAMSUM_LENGTH < $ length ) {
@@ -135,8 +146,9 @@ public function HashString($string) {
135146
136147 /* Our blocksize guess may have been way off - repeat if necessary
137148 */
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 ) {
140152
141153 $ this ->BLOCKSIZE = $ this ->BLOCKSIZE / 2 ;
142154 goto again;
0 commit comments