Tejas
Tejas

Reputation: 181

programatically get public key token using .snk file c#

Is it possible to create a .snk file programatically and using that file I want to get the public key token?

Upvotes: 2

Views: 1772

Answers (1)

DeCaf
DeCaf

Reputation: 6116

Something like this ought to do what you want:

 CspParameters parms = new CspParameters();
 parms.KeyNumber = 2;

 RSACryptoServiceProvider provider = new RSACryptoServiceProvider(parms);
 byte[] array = provider.ExportCspBlob(!provider.PublicOnly);
 StrongNameKeyPair snk = new StrongNameKeyPair(array);
 byte[] publicKey = snk.PublicKey;

Upvotes: 2

Related Questions