Source

adler32 / adler32.fs

let proceed (a, b) (x : byte) = 
    let a' = (a + (int x)) % 65521
    let b' = (a' + b) % 65521
    (a', b')
    
let adler32 data = 
    let (a, b) = Array.fold proceed (1, 0) data
    int (b <<< 16) ||| a

let load = 
    System.IO.File.ReadAllBytes
    >> adler32
    >> string
    
let args = System.Environment.GetCommandLineArgs()
let result = match args.Length with 
             | 2 -> load args.[1]
             | _ -> "Usage: Adler32 [filename]"

System.Console.WriteLine result