/// <summary> /// Gets a license key from the specified file. /// </summary> private static LicenseKey GetFromAssembly(String filename) { LicenseKey result; Assembly assembly = LicenseKey.GetEntryAssembly(); String resourceName = String.Format("{0}.{1}", assembly.GetName().Name, filename); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) result = LicenseKey.GetFromText(reader.ReadToEnd()); return(result); }
/// <summary> /// Generates a new 4096-bit licensing key. /// </summary> internal static LicenseKey CreateNew() { LicenseKey result; using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider(4096)) { result = new LicenseKey(provider.ExportParameters(true)); String asmbPath = Path.GetDirectoryName(LicenseKey.GetEntryAssembly().CodeBase.Substring(8)); result.Save(Path.Combine(asmbPath, "consensus.key"), true); result.Save(Path.Combine(asmbPath, "consensus.lic"), false); } return(result); }
/// <summary> /// Gets a license key from the specified file. /// </summary> private static LicenseKey GetFromFile(String filename) { LicenseKey result = null; // Validate that the key exists String asmbPath = Path.GetDirectoryName(LicenseKey.GetEntryAssembly().CodeBase.Substring(8)); String filePath = Path.Combine(asmbPath, filename); if (File.Exists(filePath)) { result = LicenseKey.GetFromText(File.ReadAllText(filePath)); } return(result); }