<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to check if the running script is encrypted in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/624766#M82350</link>
    <description>&lt;P&gt;From a running script I would like to do a check if the script is encrytped or not. This is to seperate behavior between development versions and release versions of a script without having to change variables in the code.&amp;nbsp;&lt;SPAN&gt;So something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( !Script is encrypted(),
  //Do bit of code for development version
,
  //Do bit of code for release version
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way is to check if the script starts with&amp;nbsp;&lt;SPAN&gt;"//-e12.1" which seems to be on the top of all encrypted scripts.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Left(LoadTextFile(IncludeFileList()[1]),8)== "//-e12.1";&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;But this doesn't work from VSCode as it gives:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_0-1682071059364.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52193i193395A67FBB1060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_0-1682071059364.png" alt="pauldeen_0-1682071059364.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;so you will always run the release code.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 16:08:41 GMT</pubDate>
    <dc:creator>pauldeen</dc:creator>
    <dc:date>2023-06-09T16:08:41Z</dc:date>
    <item>
      <title>How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/624766#M82350</link>
      <description>&lt;P&gt;From a running script I would like to do a check if the script is encrytped or not. This is to seperate behavior between development versions and release versions of a script without having to change variables in the code.&amp;nbsp;&lt;SPAN&gt;So something like:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If( !Script is encrypted(),
  //Do bit of code for development version
,
  //Do bit of code for release version
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way is to check if the script starts with&amp;nbsp;&lt;SPAN&gt;"//-e12.1" which seems to be on the top of all encrypted scripts.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Left(LoadTextFile(IncludeFileList()[1]),8)== "//-e12.1";&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;But this doesn't work from VSCode as it gives:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pauldeen_0-1682071059364.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52193i193395A67FBB1060/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pauldeen_0-1682071059364.png" alt="pauldeen_0-1682071059364.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;so you will always run the release code.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:08:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/624766#M82350</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2023-06-09T16:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626150#M82493</link>
      <description>&lt;P&gt;I created a wish list item for this&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 06:59:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626150#M82493</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2023-04-26T06:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626406#M82523</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/92"&gt;@pauldeen&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't tried this, but I see that encrypted scripts are wrapped in the Encrypted() function. This means that you might be able to include() a target script, parse the script to see if one of the function headers contains() the Encrypted() header.&amp;nbsp; This is vague response, but it may be possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StarfruitBob_0-1682531071362.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52381i2C724244AA32E7B1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StarfruitBob_0-1682531071362.png" alt="StarfruitBob_0-1682531071362.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's where within the JMP Documentation Library.pdf I screenshotted the information from for JMP 17.0.0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StarfruitBob_1-1682531224043.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52382iC2F974A383FCF58A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StarfruitBob_1-1682531224043.png" alt="StarfruitBob_1-1682531224043.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 17:48:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626406#M82523</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-04-26T17:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626419#M82525</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//
// This reports if the isEncrypted function is
// encrypted, NOT some file it might be called from.
// It works because part of the JSL encryption tries
// to prevent the internals (like expressions) of
// your JSL from being converted to text that could
// be printed.
//

isEncrypted = Function( {},
	{x},
	x = Expr( 1 + 1 );
	Char( Name Expr( x ) ) != "1 + 1";
);

write("\!n isEncrypted()=",isEncrypted(),"\!n");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2023 18:31:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626419#M82525</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-04-26T18:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626494#M82531</link>
      <description>&lt;P&gt;Our vscode extension can't even really run encrypted stuff from the editor unless it's an include.&amp;nbsp; If it's safe to assume encryption is all or nothing, then I think&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;is probably the best option.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to it to be module specific, that's harder as we don't run the expression as an include (because sometimes the file isn't saved so it wouldn't be an include).&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depends on how you're setting up scopes.&amp;nbsp; Maybe you could just hardcode the name of the file instead of using the includefilelist()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example.&amp;nbsp; I created a script `test.jsl`&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to here(1);
isEncrypted = Left(LoadTextFile("test.jsl"),9)== "//-e6.0.2"; // I had to edit this because that's what my encryption gives.  

if(isEncrypted, 
    print("This script is encrypted"),
    print("This script is not encrypted")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If I encrypt that script then include it from another script in vscode I can get.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vince_faller_0-1682549376758.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/52390i38EF5F744995955D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vince_faller_0-1682549376758.png" alt="vince_faller_0-1682549376758.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This definitely isn't perfect and assumes A LOT about your structure.&amp;nbsp; But maybe that's helpful?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Either way I've made an issue in the&amp;nbsp;&lt;A href="https://gitlab.com/predictum/jsl-for-vscode/-/issues/88" target="_self"&gt;GitLab Repo&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/19176"&gt;@ben_ph&lt;/a&gt;&amp;nbsp;maybe you can think of a better workaround?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 22:52:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/626494#M82531</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2023-04-26T22:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/627602#M82612</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks all for your suggestions! My goal was to do development work in VSCode, then encrypt and package the whole thing up in an add-in. So this is about checking if the main file is encrypted, when it is run in JMP directly or in development mode while still within VS Code. Craige's solution gives me the functionality I was looking for!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 11:50:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/627602#M82612</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2023-05-01T11:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if the running script is encrypted</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/628034#M82638</link>
      <description>&lt;P&gt;Careful relying on the encryption -- it is quite simple to beat unless you're using functions -- as in, an encrypted file that is one function and nothing else is pretty secure, but if it's classes or just a generic script, it is quite easy to get the OG script out.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 22:41:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-check-if-the-running-script-is-encrypted/m-p/628034#M82638</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2023-05-02T22:41:08Z</dc:date>
    </item>
  </channel>
</rss>

