Exemple #1
0
        static void Test3()
        {
            //配置对象
            SerialKeyConfiguration skc = new SerialKeyConfiguration();
            //生成key对象
            Generate CreateAKey = new Generate(skc);
            //
            string trialKey = CreateAKey.doKey(30); //试用版30天期限

            //创建1个有时间限制的试用版
            skc.Features = new bool[8] {
                true, false, false, false, false, false, false, false
            };
            // 当然这里的版本可以自定义,只要你自己认识就行了
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var gen = new Generate();

            gen.secretPhase = _secretPhase;
            var key = gen.doKey(999, DateTime.Now);

            Console.WriteLine($"Key: {key}");
            Debug.WriteLine($"Key: {key}");

            var serialKeyConfig = new SerialKeyConfiguration {
                addSplitChar = true, Features = new bool[] { true }, Key = key
            };
            var validate = new Validate(serialKeyConfig);

            validate.secretPhase = _secretPhase;
            Console.WriteLine($"Valid: {validate.IsValid}");
            //Console.WriteLine("Correct Machine: {0}", validate.IsOnRightMachine);
            //Console.WriteLine("Expired: {0}", validate.IsExpired);

            Console.Read();
        }
Exemple #3
0
        public void CreateAndValidateC()
        {
            SerialKeyConfiguration skm = new SerialKeyConfiguration();

            Generate gen = new Generate(skm);

            skm.Features[0] = true;
            gen.SecretPhase = "567";
            string a = gen.DoKey(37);


            Validate val = new Validate();

            val.Key         = a;
            val.SecretPhase = "567";

            Assert.IsTrue(val.IsValid == true);
            Assert.IsTrue(val.IsExpired == false);
            Assert.IsTrue(val.SetTime == 37);
            Assert.IsTrue(val.Features[0] == true);
            Assert.IsTrue(val.Features[1] == false);
        }
Exemple #4
0
        public KeyInfo GetKeyInfo(string Key, string secretPhase)
        {
            SerialKeyConfiguration skc = new SerialKeyConfiguration();
            Validate validate          = new Validate(skc);

            validate.Key         = Key;
            validate.secretPhase = secretPhase;

            KeyInfo keyInfo = new KeyInfo();

            keyInfo.IsExpired        = validate.IsExpired;
            keyInfo.SetTime          = validate.SetTime;
            keyInfo.DaysLeft         = validate.DaysLeft;
            keyInfo.CreationDate     = validate.CreationDate;
            keyInfo.IsValid          = validate.IsValid;
            keyInfo.Features         = validate.Features;
            keyInfo.Key              = validate.Key;
            keyInfo.MachineCode      = validate.MachineCode;
            keyInfo.IsOnRightMachine = validate.IsOnRightMachine;

            return(keyInfo);
        }
 public Validate(SerialKeyConfiguration _serialKeyConfiguration)
 {
     skc = _serialKeyConfiguration;
 }
 public Generate(SerialKeyConfiguration _serialKeyConfiguration)
 {
     skc = _serialKeyConfiguration;
 }