2 people like it.

Compute MD5 hash of a string

Compute MD5 hash of a string

1: 
2: 
3: 
4: 
5: 
6: 
7: 
   let MD5Hash (input : string) =
      use md5 = System.Security.Cryptography.MD5.Create()
      input
      |> System.Text.Encoding.ASCII.GetBytes
      |> md5.ComputeHash
      |> Seq.map (fun c -> c.ToString("X2"))
      |> Seq.reduce (+)
val MD5Hash : input:string -> string

Full name: Script.MD5Hash
val input : string
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string
val md5 : System.Security.Cryptography.MD5
namespace System
namespace System.Security
namespace System.Security.Cryptography
type MD5 =
  inherit HashAlgorithm
  static member Create : unit -> MD5 + 1 overload

Full name: System.Security.Cryptography.MD5
System.Security.Cryptography.MD5.Create() : System.Security.Cryptography.MD5
System.Security.Cryptography.MD5.Create(algName: string) : System.Security.Cryptography.MD5
namespace System.Text
type Encoding =
  member BodyName : string
  member Clone : unit -> obj
  member CodePage : int
  member DecoderFallback : DecoderFallback with get, set
  member EncoderFallback : EncoderFallback with get, set
  member EncodingName : string
  member Equals : value:obj -> bool
  member GetByteCount : chars:char[] -> int + 3 overloads
  member GetBytes : chars:char[] -> byte[] + 5 overloads
  member GetCharCount : bytes:byte[] -> int + 2 overloads
  ...

Full name: System.Text.Encoding
property System.Text.Encoding.ASCII: System.Text.Encoding
System.Text.Encoding.GetBytes(s: string) : byte []
System.Text.Encoding.GetBytes(chars: char []) : byte []
System.Text.Encoding.GetBytes(chars: char [], index: int, count: int) : byte []
System.Text.Encoding.GetBytes(chars: nativeptr<char>, charCount: int, bytes: nativeptr<byte>, byteCount: int) : int
System.Text.Encoding.GetBytes(s: string, charIndex: int, charCount: int, bytes: byte [], byteIndex: int) : int
System.Text.Encoding.GetBytes(chars: char [], charIndex: int, charCount: int, bytes: byte [], byteIndex: int) : int
System.Security.Cryptography.HashAlgorithm.ComputeHash(buffer: byte []) : byte []
System.Security.Cryptography.HashAlgorithm.ComputeHash(inputStream: System.IO.Stream) : byte []
System.Security.Cryptography.HashAlgorithm.ComputeHash(buffer: byte [], offset: int, count: int) : byte []
module Seq

from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val c : byte
System.Byte.ToString() : string
System.Byte.ToString(provider: System.IFormatProvider) : string
System.Byte.ToString(format: string) : string
System.Byte.ToString(format: string, provider: System.IFormatProvider) : string
val reduce : reduction:('T -> 'T -> 'T) -> source:seq<'T> -> 'T

Full name: Microsoft.FSharp.Collections.Seq.reduce

More information

Link:http://fssnip.net/lK
Posted:10 years ago
Author:Kit Eason
Tags: cryptography