-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
863a5dd
commit c57bc97
Showing
4 changed files
with
100 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.IO; | ||
using System.Text; | ||
|
||
public class PublicKeyUtils | ||
{ | ||
public static byte[] GetPublicKey(byte[] snk) | ||
{ | ||
var snkp = new System.Reflection.StrongNameKeyPair(snk); | ||
byte[] publicKey = snkp.PublicKey; | ||
return publicKey; | ||
} | ||
|
||
public static byte[] GetPublicKey(string container) | ||
{ | ||
var snkp = new System.Reflection.StrongNameKeyPair(container); | ||
byte[] publicKey = snkp.PublicKey; | ||
return publicKey; | ||
} | ||
|
||
public static string ByteArrayToString(byte[] ba) | ||
{ | ||
StringBuilder hex = new StringBuilder(ba.Length * 2); | ||
foreach (byte b in ba) | ||
hex.AppendFormat("{0:x2}", b); | ||
return hex.ToString(); | ||
} | ||
|
||
public static string GetPublicKeyStringFromContainer(string AssemblyKeyContainerName) | ||
{ | ||
byte[] publicKey2 = GetPublicKey(AssemblyKeyContainerName); | ||
string output2 = ByteArrayToString(publicKey2); | ||
return ", PublicKey=" + output2; | ||
} | ||
|
||
public static string GetPublicKeyStringFromFilename(string AssemblyOriginatorKeyFile) | ||
{ | ||
byte[] snk = File.ReadAllBytes(AssemblyOriginatorKeyFile); | ||
byte[] publicKey1 = GetPublicKey(snk); | ||
string output1 = ByteArrayToString(publicKey1); | ||
return ", PublicKey=" + output1; | ||
} | ||
} |
This file contains 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
This file contains 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