/// <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); }
/// <summary> /// Get a random number so we can add it into the license key string. /// </summary> /// <param name="numberLength">The size of the field.</param> private void GetRandomNumber(int numberLength) { var remain = numberLength % 4; if (remain != 0) { throw new ApplicationException("For Bits values each block should be a multiple of 4"); } numberLength = numberLength / 4; var rndnum = _rnd.Next(numberLength); _strLicensekey = _strLicensekey + NumberDisplay.CreateNumberString((uint)rndnum, numberLength); }
/// <summary> /// Get a random number so we can add it into the license key string. /// </summary> /// <param name="numberLength">The size of the field.</param> private void GetRandomNumber(int numberLength) { int rndnum; int remain; // // 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; } rnd.SetMaxLength(numberLength); rndnum = rnd.GetRandomNumber(); strLicensekey = strLicensekey + NumberDisplay.CreateNumberString((uint)rndnum, numberLength, UseBase10); }
/// <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); }