Created
December 15, 2016 12:54
-
-
Save theburningmonk/6009a74d2d3408a4808a49b2b145dace to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hex = | |
| seq { | |
| yield! Seq.zip { 0uy..9uy } { '0'..'9' } | |
| yield! Seq.zip { 10uy..15uy } { 'a'..'f' } | |
| } | |
| |> Map.ofSeq | |
| let hash (input : string) = | |
| let bytes = input |> Encoding.UTF8.GetBytes |> md5.ComputeHash | |
| let chars = Array.zeroCreate<char> (bytes.Length * 2) | |
| bytes |> Seq.iteri (fun i b -> | |
| chars.[i*2] <- hex.[b / 16uy] | |
| chars.[i*2+1] <- hex.[b % 16uy]) | |
| new String(chars) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment