예제 #1
0
        /// <summary>
        /// Generate new serial key.
        /// </summary>
        /// <param name="timeLeft">Number of days left.</param>
        /// <param name="creationDate">Serial key creation date.</param>
        /// <param name="features">Features available for license.</param>
        /// <param name="machineCode">Unique ID (usually machine code; get using <see cref="MachineIdentificator.GetMachineCode"/>.</param>
        /// <returns>Unique serial key based on specified information(s).</returns>
        public string GenerateSerial(int timeLeft, DateTime creationDate, bool[] features, int machineCode = 0)
        {
            var data = new KeyData
            {
                TimeLeft     = timeLeft,
                CreationDate = creationDate,
                Features     = features,
                MachineCode  = machineCode,
            };

            return(GenerateSerial(data));
        }
예제 #2
0
        /// <summary>
        /// Generate new serial key.
        /// </summary>
        /// <param name="data">Serial key information(s).</param>
        /// <returns>Unique serial key based on specified information(s).</returns>
        public string GenerateSerial(KeyData data)
        {
            if (data.TimeLeft > 999)
            {
                throw new ArgumentException("The timeLeft is larger than 999. It can only consist of three digits.");
            }
            if (data.MachineCode > 99999)
            {
                throw new ArgumentException("Machine ID is larger than 99,999. It can only consist of five digits.");
            }

            //if no exception is thown, do following
            if (!(data.MachineCode > 0 & data.MachineCode <= 99999))
            {
                data.MachineCode = GenerateRandomNumber();
            }

            //compute
            var computed   = _ska.ComputeData(data.TimeLeft, data.Features, data.MachineCode, data.CreationDate);
            var stageThree = _ska.Store(computed);

            return(AddSplitChar ? InsertSplitChar(stageThree) : stageThree);
        }