using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; namespace FrappeMocha.Keygen { public abstract class KeygenBase { public const string CompanyLicense = "Company License"; public const string SingleUserLicense = "Single User License"; protected string Platform; protected int ByteEncoding = 0; public List Products = new List(); public abstract string Generate(int type, string paramCompany, LicenseTypes license); public abstract bool Check(string paramLicenseKey, string paramCompany, LicenseTypes license); public virtual List GenerateLicencetypes(KeygenProduct p) { List licenses = new List(); licenses.Add(CompanyLicense); licenses.Add(SingleUserLicense); return licenses; } public override string ToString() { return Platform; } public byte[] StrToByteArray(string str) { try { return Encoding.GetEncoding(this.ByteEncoding).GetBytes(str); } catch (Exception) { try { return Encoding.GetEncoding(0).GetBytes(str); } catch (Exception) { return new byte[1] { (byte)63 }; } } } public string ByteArrayToStr(byte[] barr, int index, int length) { try { return Encoding.GetEncoding(this.ByteEncoding).GetString(barr, index, length); } catch (Exception) { try { return Encoding.GetEncoding(0).GetString(barr, index, length); } catch (Exception) { return "?"; } } } } }