Source

Linq2vk / src / VkontakteAPI / Linq2vk / Data.fs

namespace Linq2vk

open System
open System.Security.Cryptography

module DataTools = 

    let UnixTimeStart = DateTime(1970, 1, 1)

    let fromUnixtime (x:int64) = 
         UnixTimeStart + TimeSpan.FromSeconds(x |> float)


    let md5 (src:string) =
        let bytes : string -> byte[] =
            System.Text.Encoding.ASCII.GetBytes
        let unbytes =
            Array.map (fun (b:byte) -> b.ToString("x2"))
                >> (fun ss -> System.String.Join("", ss))
        let md5 = MD5.Create()        
        src
            |> bytes
            |> md5.ComputeHash
            |> unbytes