1. ----------------------------------------
  2. --
  3. ----------------------------------------
  4. on adler32_bytearray (ba)
  5.   adler_base = 65521
  6.   low = 1
  7.   high = 0
  8.   len = ba.length
  9.   repeat with i = 1 to len
  10.     low = ( low + ba[i]) mod adler_base
  11.     high = ( high + low ) mod adler_base
  12.   end repeat
  13.   return high * 65536 + low
  14. end
  15.  
  16. ----------------------------------------
  17. -- faster than lingo based version!
  18. ----------------------------------------
  19. on adler32_bytearray2 (ba) --, uncompressFlag)
  20.   ba.compress()
  21.   ba.position = ba.length-3
  22.   ba.endian=#bigEndian
  23.   adler32 = ba.readInt32()
  24.   --if uncompressFlag then ba.uncompress() -- restore original ba
  25.   return adler32
  26. end
  27.  
  28. ----------------------------------------
  29. -- lingo based version, D10 compatible
  30. ----------------------------------------
  31. on adler32_string (str)
  32.   adler_base = 65521
  33.   low = 1
  34.   high = 0
  35.   len = str.length
  36.   repeat with i = 1 to len
  37.     low = ( low + chartonum(str.char[i])) mod adler_base
  38.     high = ( high + low ) mod adler_base
  39.   end repeat
  40.   return high * 65536 + low
  41. end
  42.  
  43. ----------------------------------------
  44. -- usually faster than lingo based version!
  45. ----------------------------------------
  46. on adler32_string2 (str)
  47.   ba = bytearray()
  48.   ba.writeRawString(str, str.length)
  49.   ba.compress()
  50.   ba.position = ba.length-3
  51.   ba.endian=#bigEndian
  52.   return ba.readInt32()
  53. end
  54.  
  55. ----------------------------------------
  56. --
  57. ----------------------------------------
  58. on adler32_file (inputFile)
  59.   ba = file_get_bytes(inputFile)
  60.   return adler32_bytearray2(ba)
  61. end
  62.  
[raw code]