Skip to content

Instantly share code, notes, and snippets.

@riverar
Created January 28, 2018 00:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riverar/76f62919e26ba43ea64db6ffd668c710 to your computer and use it in GitHub Desktop.
Save riverar/76f62919e26ba43ea64db6ffd668c710 to your computer and use it in GitHub Desktop.
// Rafael Rivera
// License: MIT
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using MhanoHarkness; // NuGet: Base3264-UrlEncoder
namespace PublisherId_Sample
{
class Program
{
static void Main(string[] args)
{
using (var sha = SHA256.Create())
{
var publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US";
var hash = sha.ComputeHash(Encoding.Unicode.GetBytes(publisher)).Take(8).ToArray();
Console.WriteLine($"Publisher\t: {publisher}");
Console.WriteLine($"Publisher ID\t: {Base3264Encoding.ToBase32Crockford(hash).ToLower()}");
Console.ReadKey();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment