$DIFF = vec($A, $i, 8) - vec($B, $i, 8);
As I warned you over a year ago, vec on strings that happen to contain Unicode code points is now a fatal error, as of the newly released 5.32 it dies with "Use of strings with code points over 0xFF as arguments to vec is forbidden". Simply documenting "Illegal characters can mess up the result" is not robust. Sorry, but I've commented on it often enough: while you're free to code as you like, I can no longer recommend to anyone to use your "reinvented wheel" code.
Update: Added more links.
Please mark your updates as such.