Skip to content

Instantly share code, notes, and snippets.

@Thorium
Created March 4, 2012 10:43
Show Gist options
  • Save Thorium/1972350 to your computer and use it in GitHub Desktop.
Save Thorium/1972350 to your computer and use it in GitHub Desktop.
SHA512 hash code from a string
let generateHash text =
let getbytes : (string->byte[]) = System.Text.Encoding.UTF8.GetBytes
use algorithm = new System.Security.Cryptography.SHA512Managed()
text |> (getbytes >> algorithm.ComputeHash >> System.Convert.ToBase64String)
//use example:
let id, time, secretkey = "1", System.DateTime.Now.ToString("yyyyMMddhhmmss"), "mysecret"
generateHash (secretkey + id + time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment