Advertisement
Guest User

Untitled

a guest
May 29th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. open System
  2. open System.IO
  3. open System.Reflection
  4. open System.Security.Cryptography
  5.  
  6. let key = fsi.CommandLineArgs.[1]
  7. let stream = new System.IO.FileStream(key, System.IO.FileMode.Open, System.IO.FileAccess.Read)
  8. let pair = new StrongNameKeyPair(stream)
  9.  
  10. // get the public key token as 8 bytes from the end of a SHA1 hash of the key material
  11. let hash = new System.Security.Cryptography.SHA1CryptoServiceProvider()
  12. let token = hash.ComputeHash(pair.PublicKey)
  13. |> Array.rev
  14. |> Seq.take 8
  15.  
  16.  
  17. let patchArray s =
  18. s
  19. |> Seq.map (fun (x:byte) -> x.ToString("X2").ToLower() )
  20. |> Seq.toList
  21.  
  22. let rec chunkArray (s:string list) =
  23. let chunk = 39
  24. s
  25. |> Seq.truncate chunk
  26. |> Seq.iter Console.Write
  27. Console.WriteLine(String.Empty)
  28. if chunk > (List.length s ) then ()
  29. else s
  30. |> Seq.skip chunk
  31. |> Seq.toList
  32. |> chunkArray
  33.  
  34. let dumpArray s =
  35. s
  36. |> patchArray
  37. |> chunkArray
  38.  
  39. Console.WriteLine("Public key is")
  40. pair.PublicKey
  41. |> dumpArray
  42. Console.WriteLine(String.Empty)
  43.  
  44. Console.Write("Public key token is ")
  45. token
  46. |> dumpArray
  47. Console.WriteLine(String.Empty)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement