I'm working on a project that aims to simplify writing assemblies dynamically, and one thing I've been trying to work out is how to sign the assembly with a strong name, without relying on a secondary program to construct the strong name (such as sn.exe). The documentation mentions that it uses SHA1 as a hash algorithm, but as to how you set the strong name properly, I haven't been able to deduce yet.
I've tried creating a strong name with a SHA1 result from a random byte-array, but in setting the PublicKey and PublicKeyToken to what it implies (the public key is the hash of the byte array I created, or the byte-array I created) and setting the public key token to the last eight bytes of the SHA hash, I get errors when calling the AssemblyBuilder.Save() method.
Every time I get an exception saying the public key is invalid. Is there something I've missed in this?
Thanks in advance.