Last active
January 3, 2016 10:08
-
-
Save miklund/014eba747ef326df3b6d to your computer and use it in GitHub Desktop.
2010-12-08 Generate machine keys with F#
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
# Title: Generate machine keys with F# | |
# Author: Mikael Lundin | |
# Link: http://blog.mikaellundin.name/2010/12/08/generate-machine-keys-with-fsharp.html |
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
type MachineKey = { sha1 : string; aes : string; _3des : string } | |
let machineKey = { sha1 = (gen 128); aes = (gen 64); _3des = (gen 48) } | |
printfn "<machineKey validationKey=\"%s\" decryptionKey=\"%s\" validation=\"SHA1\" decryption=\"AES\" />" | |
machineKey.sha1 | |
machineKey.aes |
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 gen len = | |
let provider = new System.Security.Cryptography.RNGCryptoServiceProvider() | |
let out : byte array = Array.zeroCreate (len / 2) | |
provider.GetBytes(out) | |
out |> Seq.map (fun b -> System.String.Format("{0:X2}", b)) |> System.String.Concat |
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
<machineKey | |
validationKey="E2063661CB8652441A7B687309A5F688C95CFC71513334CBE4CE8AE7F73404C468B784EA7A1BFDECD514572D4330383879A4AE418119B65C9755A30D0208FC8A" | |
decryptionKey="1047AF920BE7770803DF9ECBDC1FDB73F3AF0C8D9F71C1C8E0D7B8260AFE607D" | |
validation="SHA1" | |
decryption="AES" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment