Skip to content

Instantly share code, notes, and snippets.

@Thorium
Created April 13, 2016 14:46
Show Gist options
  • Save Thorium/72a4bffca190c53b934e406d6135d1fe to your computer and use it in GitHub Desktop.
Save Thorium/72a4bffca190c53b934e406d6135d1fe to your computer and use it in GitHub Desktop.
Calculate MD5 hash that can be used when interacting with a PHP-website. Note: MD5 has been cracked and shouldn't be used in new systems.
let phpMd5 (dataToHash:string) =
use md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
let encodedBytes = dataToHash |> System.Text.ASCIIEncoding.Default.GetBytes |> md5.ComputeHash
System.Text.RegularExpressions.Regex.Replace(System.BitConverter.ToString(encodedBytes), "-", "").ToLower()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment