Exemplo n.º 1
0
        /// <summary>
        /// Checks if the current license key is on the correct device with SHA-256 as the hash function.
        /// </summary>
        /// <param name="licenseKey">The license key object.</param>
        /// <param name="isFloatingLicense">If this is a floating license, this parameter has to be set to true.
        /// You can enable floating licenses by setting <see cref="V3.Models.ActivateModel.FloatingTimeInterval"/>
        /// to a value greater than 0.</param>
        /// <param name="allowOverdraft">If floating licensing is enabled with overdraft, this parameter should be set to true.
        /// You can enable overdraft by setting <see cref="ActivateModel.MaxOverdraft"/> to a value greater than 0.
        ///</param>
        /// <param name="platformIndependent">Allows you to specify if you want to use the old machine code method that is based on COM and requires
        /// System.Management or use the new platform independent method, i.e. <see cref="GetMachineCodePI"/>.
        /// </param>
        /// <returns></returns>
        public static bool IsOnRightMachine(LicenseKey licenseKey, bool isFloatingLicense = false, bool allowOverdraft = false, bool platformIndependent = false)
        {
#if !SYSTEM_MANAGEMENT
            platformIndependent = true;
#endif

            if (platformIndependent)
            {
                return(licenseKey.IsOnRightMachine(GetMachineCodePI(), isFloatingLicense, allowOverdraft).IsValid());
            }
            else
            {
                return(licenseKey.IsOnRightMachine(SKGL.SKM.getSHA256, isFloatingLicense, allowOverdraft).IsValid());
            }
        }
Exemplo n.º 2
0
        public void IsOnRightMachineTest()
        {
            var ki = new LicenseKey {
                ActivatedMachines = new List <ActivationData>()
                {
                    new ActivationData {
                        Mid = "test"
                    }
                }
            };

            var result = ki.IsOnRightMachine().IsValid();

            Assert.IsFalse(ki.IsOnRightMachine().IsValid());

            ki.ActivatedMachines[0].Mid = SKGL.SKM.getMachineCode(SKGL.SKM.getSHA1);

            Assert.IsTrue(ki.IsOnRightMachine().IsValid());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if the current license key is on the correct device.
 /// </summary>
 /// <param name="licenseKey">The license key object.</param>
 /// <returns></returns>
 public static bool IsOnRightMachine(LicenseKey licenseKey)
 {
     return(licenseKey.IsOnRightMachine(SKGL.SKM.getSHA256).IsValid());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Checks if the current license key is on the correct device with SHA-256 as the hash function.
 /// </summary>
 /// <param name="licenseKey">The license key object.</param>
 /// <param name="machineCode">A unique identifier of the machine.</param>
 /// <param name="isFloatingLicense">If this is a floating license, this parameter has to be set to true.
 /// You can enable floating licenses by setting <see cref="V3.Models.ActivateModel.FloatingTimeInterval"/>
 /// to a value greater than 0.</param>
 /// <param name="allowOverdraft">If floating licensing is enabled with overdraft, this parameter should be set to true.
 /// You can enable overdraft by setting <see cref="ActivateModel.MaxOverdraft"/> to a value greater than 0.
 ///</param>
 /// <returns></returns>
 public static bool IsOnRightMachine(LicenseKey licenseKey, string machineCode, bool isFloatingLicense = false, bool allowOverdraft = false)
 {
     return(licenseKey.IsOnRightMachine(machineCode, isFloatingLicense, allowOverdraft).IsValid());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Checks if the current license key is on the correct device with SHA-256 as the hash function.
 /// </summary>
 /// <param name="licenseKey">The license key object.</param>
 /// <param name="isFloatingLicense">If this is a floating license, this parameter has to be set to true.
 /// You can enable floating licenses by setting <see cref="V3.Models.ActivateModel.FloatingTimeInterval"/>
 /// to a value greater than 0.</param>
 /// <param name="allowOverdraft">If floating licensing is enabled with overdraft, this parameter should be set to true.
 /// You can enable overdraft by setting <see cref="ActivateModel.MaxOverdraft"/> to a value greater than 0.
 ///</param>
 ///<param name="v">If version is set to 2, you can get the machine code as in the Python client,
 ///assuming similar settings are used. You can read more about it here:
 ///https://help.cryptolens.io/faq/index#machine-code-generation</param>
 /// <returns></returns>
 public static bool IsOnRightMachinePI(LicenseKey licenseKey, bool isFloatingLicense = false, bool allowOverdraft = false, int v = 1)
 {
     return(licenseKey.IsOnRightMachine(GetMachineCodePI(v), isFloatingLicense, allowOverdraft).IsValid());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Checks if the current license key is on the correct device with SHA-256 as the hash function.
 /// </summary>
 /// <param name="licenseKey">The license key object.</param>
 /// <param name="isFloatingLicense">If this is a floating license, this parameter has to be set to true.
 /// You can enable floating licenses by setting <see cref="V3.Models.ActivateModel.FloatingTimeInterval"/>
 /// to a value greater than 0.</param>
 /// <returns></returns>
 public static bool IsOnRightMachine(LicenseKey licenseKey, bool isFloatingLicense = false)
 {
     return(licenseKey.IsOnRightMachine(SKGL.SKM.getSHA256, isFloatingLicense).IsValid());
 }