HISE Logo Forum
    • Categories
    • Register
    • Login

    Simple copy protection done right :)

    Scheduled Pinned Locked Moved Presets / Scripts / Ideas
    151 Posts 25 Posters 17.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User @orange
      last edited by

      @orange said in Simple copy protection done right :):

      @staiff in
      Use the latest (updated today) HISE version.
      Use Authorisation.js code with Content.makeFrontInterface like below. Also don't forget to include("Serials.js") to make the function check. All of the UI elements will be activated. I tried and compiled a plugin, it works likea charm. It creates "RegistrationInfo.js" in User presets main folder. Interface code example is this;

      Content.makeFrontInterface(600, 500);
      
      
      include("Serials.js");
      
      
      
      namespace Authorisation
      {
          const var SerialInput = Content.getComponent("SerialInput");
          const var Description = Content.getComponent("Description");
          const var SerialStateLabel = Content.getComponent("SerialStateLabel");
          const var AuthorisationDialogue = Content.getComponent("AuthorisationDialogue");
          const var GlobalMute = Synth.getMidiProcessor("GlobalMute");
          
          /** Checks if the serial input is valid and stores the result if successful. */
          inline function onSubmitButtonControl(component, value)
          {
              if(!value) // Just execute once
                  return;
          
              local v = SerialInput.getValue();
              Console.print(v);
      	
              // Checks if it's in the input
              if(serials.Data.contains(v))
              {
                  Console.print("Serial number found");
              
                  local data = 
                  {
                      "Serial": v
                  };
              
                  // Stores the file to the hard drive. In HISE it will be the project folder
                  // but in the compiled plugin it will use the parent directory to the 
                  // user preset directory (which is usually the app data folder).
                  Engine.dumpAsJSON(data, "../RegistrationInfo.js");
                  
                  setValidLicense(true);
              }
              else
              {
                  Console.print("Invalid serial number");
                  Description.set("text", "Invalid serial number. The number you supplied does not match");
                  
                  setValidLicense(false);
              }
          };
      
          Content.getComponent("SubmitButton").setControlCallback(onSubmitButtonControl);
      
      
          inline function setValidLicense(isValid)
          {
              // Do whatever you want to do here. I suggest a MIDI muter...
              GlobalMute.setAttribute(0, 1 - isValid);
          
              if(isValid)
              {
                  // Change this to any other visual indication...
                  SerialStateLabel.set("bgColour", Colours.greenyellow);
                  AuthorisationDialogue.set("visible", false);
              }
              else
              {
                  SerialStateLabel.set("bgColour", Colours.red);
                  AuthorisationDialogue.set("visible", true);
              }
          }
      
          inline function checkOnLoad()
          {
              // Clear the input
              SerialInput.set("text", "");
              
              // Load the serial from the stored file
              local pData = Engine.loadFromJSON("../RegistrationInfo.js");
              Console.print("Checking serial");
          
              if(pData)    
              {
                  local v = pData.Serial;
                  Console.print("Restored serial: " + v);
              
                  if(serials.Data.contains(v))
                  {
                      setValidLicense(true);
                      return;
                  }
              }
          
              setValidLicense(false);
          }
      
          // Call this on startup
          checkOnLoad();
      
      }
      

      @nesta99

      1 Reply Last reply Reply Quote 0
      • M
        mwplugs
        last edited by

        welp. im guessing simple copy protection is broken or depreciated in current HISE

        worked like a charm since 2020 now...

        it registers license keys does everything right then...when recompiled or reopened it says invalid serial even though it is in the registration file and said it was correct initially

        Interface: Checking serial
        Interface: Restored serial: 4E6I-52DH-17X1-OE54
        Interface: 
        Interface: Invalid serial number
        

        in fact it doesnt even look like its checking it after restoring basic on what the console is saying there.

        again this is the exact code. exact implementation as above..worked for years now it doesnt for some reason
        all gui elements are created and match changed GlobalMute to Mute for an audio mute opposed to midi

        namespace Authorisation
        {
            const var SerialInput = Content.getComponent("SerialInput");
            const var Description = Content.getComponent("Description");
            const var AuthorisationDialogue = Content.getComponent("AuthorisationDialogue");
            const var Mute = Synth.getEffect("Mute");
            
            /** Checks if the serial input is valid and stores the result if successful. */
            inline function onSubmitButtonControl(component, value)
            {
                if(!value) // Just execute once
                    return;
            
                local v = SerialInput.getValue();
                Console.print(v);
        	
                // Checks if it's in the input
                if(serials.Data.contains(v))
                {
                    Console.print("Serial number found");
                
                    local data = 
                    {
                        "Serial": v
                    };
                
                    // Stores the file to the hard drive. In HISE it will be the project folder
                    // but in the compiled plugin it will use the parent directory to the 
                    // user preset directory (which is usually the app data folder).
                    Engine.dumpAsJSON(data, "../RegistrationInfo.js");
                    
                    setValidLicense(true);
                }
                else
                {
                    Console.print("Invalid serial number");
                    Description.set("text", "Invalid serial number. The number you supplied does not match");
                    
                    setValidLicense(false);
                }
            };
        
            Content.getComponent("SubmitButton").setControlCallback(onSubmitButtonControl);
        
        
            inline function setValidLicense(isValid)
            {
                // Do whatever you want to do here. I suggest a MIDI muter...
                Mute.setBypassed(value - isValid);
            
                if(isValid)
                {
                    // Change this to any other visual indication...
        
                    AuthorisationDialogue.set("visible", false);
                }
                else
                {
        
                    AuthorisationDialogue.set("visible", true);
                }
            }
        
            inline function checkOnLoad()
            {
                // Clear the input
                SerialInput.set("text", "");
                
                // Load the serial from the stored file
                local pData = Engine.loadFromJSON("../RegistrationInfo.js");
                Console.print("Checking serial");
            
                if(pData)    
                {
                    local v = pData.Serial;
                    Console.print("Restored serial: " + v);
                
                    if(serials.Data.contains(v))
                    {
                        setValidLicense(true);
                        return;
                    }
                }
            
                setValidLicense(false);
            }
        
            // Call this on startup
            checkOnLoad();
        
        }
        
        M 1 Reply Last reply Reply Quote 0
        • M
          mwplugs @mwplugs
          last edited by

          @mwplugs haha i figured out something really weird...

          so i look in the sample project etc. and reference times it has worked right.

          but i discovered that for some reason now..when the submit button has save in preset enabled the whole script doesnt work. although previously it didnt matter but now it does. so if anyone runs into that take a look

          S 2 Replies Last reply Reply Quote 0
          • S
            Sawer @mwplugs
            last edited by

            @mwplugs Hi, so I should deactivate the saveInPreset on the Submit button to make it fully work?

            1 Reply Last reply Reply Quote 0
            • S
              Sawer @mwplugs
              last edited by

              @mwplugs Ok so, when I opened the snippet, the button is already not set as saveInPreset, and it work like a charm.
              I don't know how happened to not work on your side.

              1 Reply Last reply Reply Quote 0
              • Adam_GA
                Adam_G
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • S
                  Sampletekk
                  last edited by

                  Trying to run this but I get this when it loads: Skärmavbild 2025-02-09 kl. 17.05.08.png

                  Oli UllmannO 1 Reply Last reply Reply Quote 0
                  • Oli UllmannO
                    Oli Ullmann @Sampletekk
                    last edited by

                    @Sampletekk
                    The project no longer works like this. You have to copy the code and set it up yourself. Then it will work.

                    I did this some time ago. You can download it here (You must download it within 7 days, otherwise the link will expire!):

                    https://we.tl/t-XP43QVzxLK

                    S 1 Reply Last reply Reply Quote 1
                    • S
                      Sampletekk @Oli Ullmann
                      last edited by

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • S
                        Sampletekk
                        last edited by

                        Struggeling with this! When I run the program now, I'm getting this:

                        Skärmavbild 2025-02-10 kl. 21.26.58.png

                        Any ideas?

                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Sampletekk
                          last edited by

                          @Sampletekk Unknown function mean the thing on the left side of the . doesn't have a function with that name - so you need to check that serials.Data has the values you think it should.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          S 1 Reply Last reply Reply Quote 0
                          • S
                            Sampletekk @d.healey
                            last edited by

                            @d-healey said in Simple copy protection done right :):

                            @Sampletekk Unknown function mean the thing on the left side of the . doesn't have a function with that name - so you need to check that serials.Data has the values you think it should.

                            Aha! The file created, that contains the valid numbers, is called "serials.js". Is this the problem here?

                            d.healeyD 1 Reply Last reply Reply Quote 0
                            • d.healeyD
                              d.healey @Sampletekk
                              last edited by

                              @Sampletekk said in Simple copy protection done right :):

                              Is this the problem here?

                              I don't know, I'm not familiar with the rest of the code.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              1 Reply Last reply Reply Quote 0
                              • S
                                Sampletekk
                                last edited by

                                Ok, I've got this working! One question: When working in the Hise, after entering a valid serial, The script creates the file "RegistrationInfo.js" in the projects root.
                                Where does that file end up when you are working with a compiled version? I'm on a mac now, but I'm also interested in knowing where it is on a PC.
                                For testing purposes, I would like to be able to "reset" the registration for the compiled versions, as I would do while developing, by deleting the "RegistrationInfo.js" file

                                LindonL 1 Reply Last reply Reply Quote 0
                                • LindonL
                                  Lindon @Sampletekk
                                  last edited by

                                  @Sampletekk try looking in the App Data folders...

                                  HISE Development for hire.
                                  www.channelrobot.com

                                  S 1 Reply Last reply Reply Quote 0
                                  • S
                                    Sampletekk @Lindon
                                    last edited by

                                    @Lindon said in Simple copy protection done right :):

                                    @Sampletekk try looking in the App Data folders...

                                    Found it, on a mac, it was in the "Application Support" folder!

                                    LindonL 1 Reply Last reply Reply Quote 0
                                    • LindonL
                                      Lindon @Sampletekk
                                      last edited by

                                      @Sampletekk yep - and on windows its in

                                      C:/Users/AppData/Roaming/CompanyName/productName

                                      HISE Development for hire.
                                      www.channelrobot.com

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post

                                      49

                                      Online

                                      1.7k

                                      Users

                                      11.7k

                                      Topics

                                      102.2k

                                      Posts