using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppLibs.Libs.Crypt
{
    public class Adler32
    {
        private const uint MOD_ADLER = 65521;
        public uint ComputeHash(byte[] data)
        {
            
            uint a = 1, b = 0;

            foreach (var c in data)
            {
                a = (a + c) % MOD_ADLER;
                b = (b + a) % MOD_ADLER;
            }

            return (b << 16) | a;
        }
    }
}
