<?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 Re: Encrypting a password parameter in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615971#M20452</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can try using the getpass module for python.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/getpass.html"&gt;getpass&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;getpass works fine for standalone scripts but it seems it lock everything up if I use it in a script that is run from in ArcMap (10.0).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess that it is still waiting for input that will never arrive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I presume that this is for a similar reason to print statements not working in this environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is an parameter type for scripts (ArcGIS 10.0) called "Encrypted String" which does mask on input but I am not sure what you can do with it in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume that the original poster wanted to then pass on the parameter to something else or compare it to known values as would I.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Dec 2011 23:58:53 GMT</pubDate>
    <dc:creator>ClarrieHall</dc:creator>
    <dc:date>2011-12-28T23:58:53Z</dc:date>
    <item>
      <title>Encrypting a password parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615969#M20450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a Python geoprocessing script that needs to get a password as a parameter from the user. Right now, I am just using a "string" type. But ArcGIS (9.3.1) echoes all parameters when it starts to run the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there an (easy) way to have an encrypted/obfuscated password parameter type?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 14:07:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615969#M20450</guid>
      <dc:creator>EricWolf</dc:creator>
      <dc:date>2011-08-18T14:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Encrypting a password parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615970#M20451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can try using the getpass module for python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/getpass.html"&gt;getpass&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 15:40:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615970#M20451</guid>
      <dc:creator>TonyContreras</dc:creator>
      <dc:date>2011-08-18T15:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Encrypting a password parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615971#M20452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You can try using the getpass module for python.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/getpass.html"&gt;getpass&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;getpass works fine for standalone scripts but it seems it lock everything up if I use it in a script that is run from in ArcMap (10.0).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess that it is still waiting for input that will never arrive.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I presume that this is for a similar reason to print statements not working in this environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is an parameter type for scripts (ArcGIS 10.0) called "Encrypted String" which does mask on input but I am not sure what you can do with it in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume that the original poster wanted to then pass on the parameter to something else or compare it to known values as would I.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Dec 2011 23:58:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615971#M20452</guid>
      <dc:creator>ClarrieHall</dc:creator>
      <dc:date>2011-12-28T23:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Encrypting a password parameter</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615972#M20453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;getpass works fine for standalone scripts but it seems it lock everything up if I use it in a script that is run from in ArcMap (10.0).&lt;BR /&gt;I guess that it is still waiting for input that will never arrive.&lt;BR /&gt;I presume that this is for a similar reason to print statements not working in this environment.&lt;BR /&gt;&lt;BR /&gt;There is an parameter type for scripts (ArcGIS 10.0) called "Encrypted String" which does mask on input but I am not sure what you can do with it in the script.&lt;BR /&gt;&lt;BR /&gt;I assume that the original poster wanted to then pass on the parameter to something else or compare it to known values as would I.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've had similar issues and requirements.&amp;nbsp; My basic requirement was to allow a user to change their database password.&amp;nbsp; So what I did is use getpass in a subprocess to ask the user for a new password (and to verify the new password).&amp;nbsp; I'v essentially implemented these two methods: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import subprocess
def promptForPassword():
 pwd=promptInNewProcess()
 pwd2=promptInNewProcess("Verify the new password: ")
 return pwd,pwd2
 
def promptInNewProcess(prompt="Enter a new password: "):
 cmd=r'python -c "from getpass import getpass; pwd=getpass(\"'+prompt+r'\"); print pwd"'
 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
 out, err = p.communicate()
 if (err==None):
&amp;nbsp; return out.strip()
 return ""
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And then called these from my python script that is pointed to from a toolbox script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from OraclePasswordFunctions import promptForPassword
if __name__ == "__main__":
 if (len(sys.argv)&amp;lt;&amp;gt;2):
&amp;nbsp; print "There is 1 required input: "
&amp;nbsp; print "&amp;nbsp; - SDE connection file to an ORACLE database (.sde).&amp;nbsp; The user in the sde connection file is will be the user who's password gets changed"
&amp;nbsp; sys.exit(0)&amp;nbsp; 

 arcpy.AddMessage("\n\n\nThis utility will change the password of a SDE connection file.&amp;nbsp; A command prompt will appear and ask for a new password.&amp;nbsp; A second command prompt will then appear to validate the password (verify the inputs are the same).&amp;nbsp; This utility uses the following criteria for password strength: ")
 arcpy.AddMessage("&amp;nbsp; - 8 or more characters in length")
 arcpy.AddMessage("&amp;nbsp; - 30 or less characters in length")
 arcpy.AddMessage("&amp;nbsp; - Start with an alpha character [a..z] or [A..Z]")
 arcpy.AddMessage("&amp;nbsp; - Contain at least 1 lower case character")
 arcpy.AddMessage("&amp;nbsp; - Contain at least 1 upper case character")
 arcpy.AddMessage("&amp;nbsp; - Contain at least 1 numeric character")
 arcpy.AddMessage("&amp;nbsp; - Contain at least 1 special character.&amp;nbsp; The only special characters allowed are '_' or '#' or '$' (without quotes)")
 arcpy.AddMessage("\n\n\n")

 sde_ws = arcpy.GetParameterAsText(0)
 pwd1,pwd2=promptForPassword()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then what I did was compare pwd1 and pwd2 (to verify they met the requirements and that it was the same password).&amp;nbsp; If all succeeded then I called the arcpy.ArcSDESQLExecute methods to run an 'ALTER USER' statement&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This makes it interactive so that its not really scriptable.&amp;nbsp; A user runs the tool and it opens a command prompt (black box) that asks for their password.&amp;nbsp; When they hit enter it closes that one and opens a new command prompt asking for the user to verify the password.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:19:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/encrypting-a-password-parameter/m-p/615972#M20453</guid>
      <dc:creator>PF1</dc:creator>
      <dc:date>2021-12-12T02:19:47Z</dc:date>
    </item>
  </channel>
</rss>

