Ejemplo n.º 1
0
        /// <summary>
        /// Get the checksum number so we can add it into the license key string.
        /// </summary>
        /// <param name="licensekey">The license key string.</param>
        /// <param name="numberLength">The size of the field.</param>
        /// <param name="includeLicensekey">Include the original license key as part of the return value.</param>
        private string GetChecksumNumber(string licensekey, int numberLength, bool includeLicensekey)
        {
            //
            // create the checksum class
            //
            var chk = new Checksum();

            var remain = numberLength % 4;

            if (remain != 0)
            {
                throw new ApplicationException("For Bits values each block should be a multiple of 4");
            }
            numberLength = numberLength / 4;

            chk.ChecksumAlgorithm = ChecksumAlgorithm;
            chk.CalculateChecksum(licensekey);
            if (includeLicensekey)
            {
                var csum = chk.ChecksumNumber;
                licensekey = licensekey + NumberDisplay.CreateNumberString(csum, numberLength);
            }
            else
            {
                var csum = chk.ChecksumNumber;
                licensekey = NumberDisplay.CreateNumberString(csum, numberLength);
            }
            return(licensekey);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Get the checksum number so we can add it into the license key string.
        /// </summary>
        /// <param name="Licensekey">The license key string.</param>
        /// <param name="numberLength">The size of the field.</param>
        /// <param name="includeLicensekey">Include the original license key as part of the return value.</param>
        private string GetChecksumNumber(string Licensekey, int numberLength, bool includeLicensekey)
        {
            int      remain;
            Checksum chk;

            //
            // create the checksum class
            //
            chk = new Checksum();
            //
            // if bits has been selected then we need to check for a 4 bit multiple
            //
            if (UseBytes == false)
            {
                remain = numberLength % 4;
                if (remain != 0)
                {
                    throw new ApplicationException("For Bits values each block should be a multiple of 4");
                }
                numberLength = numberLength / 4;
            }
            chk.ChecksumAlgorithm = ChecksumAlgorithm;
            chk.CalculateChecksum(Licensekey);
            if (includeLicensekey)
            {
                uint csum;

                csum       = chk.ChecksumNumber;
                Licensekey = Licensekey + NumberDisplay.CreateNumberString(csum, numberLength, UseBase10);
            }
            else
            {
                uint csum;

                csum       = chk.ChecksumNumber;
                Licensekey = NumberDisplay.CreateNumberString(csum, numberLength, UseBase10);
            }
            return(Licensekey);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the checksum number so we can add it into the license key string. 
        /// </summary>
        /// <param name="licensekey">The license key string.</param>
        /// <param name="numberLength">The size of the field.</param>
        /// <param name="includeLicensekey">Include the original license key as part of the return value.</param>
        private string GetChecksumNumber(string licensekey, int numberLength, bool includeLicensekey)
        {
            //
            // create the checksum class
            //
            var chk = new Checksum();

            var remain = numberLength%4;
            if (remain != 0)
            {
                throw new ApplicationException("For Bits values each block should be a multiple of 4");
            }
            numberLength = numberLength/4;

            chk.ChecksumAlgorithm = ChecksumAlgorithm;
            chk.CalculateChecksum(licensekey);
            if (includeLicensekey)
            {
                var csum = chk.ChecksumNumber;
                licensekey = licensekey + NumberDisplay.CreateNumberString(csum, numberLength);
            }
            else
            {
                var csum = chk.ChecksumNumber;
                licensekey = NumberDisplay.CreateNumberString(csum, numberLength);
            }
            return licensekey;
        }