Ejemplo n.º 1
0
    //// Start is called before the first frame update
    private void Start()
    {
        // We recommend to review https://help.cryptolens.io/getting-started/unity for common errors and tips.

        var licenseKey = "GEBNC-WZZJD-VJIHG-GCMVD";
        var RSAPubKey  = "<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

        var auth   = "WyIyNjg4IiwiN3dVZjVwM2svRU5nNkhEZnpSYWdWZ3R4OUQ5R2ZFVExwbEJMNFZyMCJd";
        var result = Key.Activate(token: auth, productId: 3349, key: licenseKey, machineCode: Helpers.GetMachineCodePI());

        if (result == null || result.Result == ResultType.Error)
        {
            // an error occurred or the key is invalid or it cannot be activated
            // (eg. the limit of activated devices was achieved)
            Debug.Log(result?.Message);
            Debug.Log("The license does not work.");
        }
        else
        {
            // obtaining the license key (and verifying the signature automatically).
            var license = LicenseKey.FromResponse(RSAPubKey, result);

            // make sure to set Max Number of Machines (https://help.cryptolens.io/faq/index#maximum-number-of-machines)
            // if it's set to zero, please remove "!Helpers.IsOnRightMachinePI(license)".
            if (license == null || !Helpers.IsOnRightMachinePI(license))
            {
                Debug.Log("The license cannot be used on this device.");
                return;
            }

            // everything went fine if we are here!
            Debug.Log("The license is valid!");
        }
    }
Ejemplo n.º 2
0
        public void SignatureTestNewMethod()
        {
            var result = Key.Activate(AccessToken.AccessToken.Activate, 3349, "MTMPW-VZERP-JZVNZ-SCPZM", "test");

            if (result == null || result.Result == ResultType.Error)
            {
                Assert.Fail();
            }

            var license = LicenseKey.FromResponse("<RSAKeyValue><Modulus>sGbvxwdlDbqFXOMlVUnAF5ew0t0WpPW7rFpI5jHQOFkht/326dvh7t74RYeMpjy357NljouhpTLA3a6idnn4j6c3jmPWBkjZndGsPL4Bqm+fwE48nKpGPjkj4q/yzT4tHXBTyvaBjA8bVoCTnu+LiC4XEaLZRThGzIn5KQXKCigg6tQRy0GXE13XYFVz/x1mjFbT9/7dS8p85n8BuwlY5JvuBIQkKhuCNFfrUxBWyu87CFnXWjIupCD2VO/GbxaCvzrRjLZjAngLCMtZbYBALksqGPgTUN7ZM24XbPWyLtKPaXF2i4XRR9u6eTj5BfnLbKAU5PIVfjIS+vNYYogteQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", result);

            Assert.IsNotNull(license);
        }
Ejemplo n.º 3
0
        public void ActivateAndDeactivateNewProtocolTest()
        {
            var auth   = activateDeactivate;
            var result = Key.Activate(token: auth, productId: 3349, key: "GEBNC-WZZJD-VJIHG-GCMVD", machineCode: "foo");

            System.Diagnostics.Debug.WriteLine(result);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Result == ResultType.Success);

            Assert.IsTrue(LicenseKey.FromResponse(TestCases.TestData.pubkey, result) != null);

            var license = LicenseKey.FromResponse(TestCases.TestData.pubkey, result);

            license.SaveToFile("newprotocol.skm");

            Assert.IsTrue(license.HasValidSignature(TestCases.TestData.pubkey).IsValid());

            license = new LicenseKey().LoadFromFile("newprotocol.skm", TestCases.TestData.pubkey);

            Assert.IsTrue(license != null);
            license = new LicenseKey().LoadFromFile("newprotocol.skm");

            Assert.IsFalse(license != null);


            var result3 = Key.Activate(auth, new ActivateModel()
            {
                ProductId = 3349, Key = "GEBNC-WZZJD-VJIHG-GCMVD", MachineCode = "foo", Sign = true
            });

            result3.LicenseKey.SaveToFile("oldprotocol.skm");

            Assert.IsTrue(new LicenseKey().LoadFromFile("oldprotocol.skm") != null);
            Assert.IsTrue(new LicenseKey().LoadFromFile("oldprotocol.skm", TestCases.TestData.pubkey) != null);


            //result.LicenseKey.Signature = "test";

            //Assert.IsFalse(result.LicenseKey.IsValid(TestCases.TestData.pubkey));


            var result2 = Key.Deactivate(auth, new DeactivateModel {
                Key = "GEBNC-WZZJD-VJIHG-GCMVD", ProductId = 3349, MachineCode = "foo"
            });

            if (result2 == null || result2.Result == ResultType.Error)
            {
                Assert.Fail("The deactivation did not work");
            }
        }