<?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: save passwords securely in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230459#M45702</link>
    <description>&lt;P&gt;That would involve me having access to all users passwords.&amp;nbsp; Definitely not doable.&amp;nbsp; And telling a user to save their password as an encrypted script also isn't a viable option.&amp;nbsp; I truly want a "remember me" option where I can store whatever username/password&amp;nbsp; they type programmatically, but that storage is secure.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Oct 2019 21:28:58 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2019-10-23T21:28:58Z</dc:date>
    <item>
      <title>save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230419#M45690</link>
      <description>&lt;P&gt;Does anyone have a secure way to store passwords so users don't have to enter their password every time?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't want to just store the password as plain text in a preferences file or anything like that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
nw = new window("Login", 
	lineupbox(ncol(2), 
		textbox("Username"), teb_uid = texteditbox("Vincent", &amp;lt;&amp;lt;Set Width(200)), 
		textbox("Password"), teb_pwd = texteditbox("thisisapassword", &amp;lt;&amp;lt;Width(200), &amp;lt;&amp;lt;Password Style(1))
	), 
	cb_save = checkbox({"Remember Me"}), 
	buttonbox("OK", 
		uid = teb_uid &amp;lt;&amp;lt; Get Text();
		pwd = teb_pwd &amp;lt;&amp;lt; Get Text();
		nw &amp;lt;&amp;lt; close window();
	)
);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Oct 2019 18:19:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230419#M45690</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-10-23T18:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230443#M45697</link>
      <description>&lt;P&gt;Create a script that contains the passwords........in Associative Arrays, or in lists, etc.&amp;nbsp; Then save that script as an encrypted script.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 20:26:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230443#M45697</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-10-23T20:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230459#M45702</link>
      <description>&lt;P&gt;That would involve me having access to all users passwords.&amp;nbsp; Definitely not doable.&amp;nbsp; And telling a user to save their password as an encrypted script also isn't a viable option.&amp;nbsp; I truly want a "remember me" option where I can store whatever username/password&amp;nbsp; they type programmatically, but that storage is secure.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 21:28:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/230459#M45702</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-10-23T21:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251047#M49290</link>
      <description>&lt;P&gt;Figured I'd try to bump this to see if anyone has any ideas.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because now I'm having issues with other types of secrets as well.&amp;nbsp; User Access Codes and what not.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 19:51:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251047#M49290</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-03-06T19:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251266#M49333</link>
      <description>&lt;P&gt;Secure storage of credentials is a difficult issue. &amp;nbsp;It's really difficult to do right. &amp;nbsp;At very least you likely still need the user to enter some form of credentials once per session, to prevent unauthorized use of the secrets you are trying to protect. &amp;nbsp;So for each 'user' you will likely need to store a password for their credential store. &amp;nbsp;Then you need the credential store itself. &amp;nbsp;How secure is enough? &amp;nbsp;Do you just need obfuscation, such as a simple substitution cipher like rot13 ( shift the letters of the alphabet by 13 so m =&amp;gt; z, a =&amp;gt;n or do you need something stronger like AES encryption, or Public Key encryption? &amp;nbsp;You could create your data store using a JMP table, a text file or a database table, JMP has ODBC support for database connectivity. &amp;nbsp;Better checksums and encryption support, either written in JSL, or loaded from shared libraries via JMP's add-in capability or through the Python bridge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Securing passwords,&lt;/P&gt;
&lt;P&gt;A traditional way to keep passwords files secure it to use a hash function. &amp;nbsp;One way has functions such as MD5, the SHA family, SHA1, SHA256, ... all take data and create a hash that cannot be reversed to reveal the original data. &amp;nbsp;The idea is you take the data you want to secure and create a hash from the data. &amp;nbsp;Usually such hashes are stirred with a SALT value, a random value that is stored with the password data. &amp;nbsp;The salt make it far more costly to keep lookup tables of known data to hash values. Then when the user type in the password, you hash the entered value and compare the hash against the stored value.&amp;nbsp;If they match == success and password is validated. &amp;nbsp;JMP exposes the MD5 checksum to JSL. &amp;nbsp;From the scripting index, see Blob MD5(). Please note that MD5's use for cryptographic purposes is not secure against modern cryptographic techniques, but for low level security is still should be fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, you can use the hash or even combine the hash with additional data create a derived hash or HMAC&amp;nbsp;&lt;A href="https://en.wikipedia.org/wiki/HMAC" target="_blank"&gt;https://en.wikipedia.org/wiki/HMAC&lt;/A&gt;&amp;nbsp;to act as the password key to your protected data store. &amp;nbsp;Some databases have encrypt functionality for data fields, or you may have to encrypt the data yourself and store in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly if you need greater security, look at JMP's add-in functionality that can call into shared libraries, there you could implement as complex a data management scheme as you desire. &amp;nbsp;Or look to JMP's Python interface, calling out to Python packages can give you access to sqlite, and better checksums and encryption methods.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How I would go about building such a data store? &amp;nbsp;I would lean heavily on JMP's Python interface. &amp;nbsp;The sqlite database support is built into Python, and would use that or JMP tables for my data store. &amp;nbsp;Further Python is generally built with crypt support, checksums and encryption algorithms. &amp;nbsp;I would first start by creating a password table table which has a hash of the passwords. &amp;nbsp;Then build a data store as another table which have encrypted fields. &amp;nbsp;Just how secure, how complicated, a matter of how much code and how much testing...&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 13:28:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251266#M49333</guid>
      <dc:creator>Paul_Nelson</dc:creator>
      <dc:date>2020-03-09T13:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251411#M49355</link>
      <description>&lt;P&gt;Sample python script to create a sqlite data store,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;#! /usr/bin/env/python3
#
# Author: Paul Nelson - JMP Statistical Discovery, From SAS
# Date: 9 Mar 2020
#
# Description: This sample shows the python code using sqlite to create a data data store
# for saving passwords, credentails...  While Python has hash functions, the standard library
# does not include ciphers.  For purposes of this sample I used lzma compression to 'encode' and
# decompression to 'decrypt'  For use from JSL, I would turn this into a python module and then
# import 'my_dataStore_api' to cut down code in the JSL string.
#
# sample python program using sqlite to create a secure store for passwords and
# key, value data storage.
#
# While Python contains hash functions, does not include encryption primitives in the standard library.
# an example using PyCrypto can be found
# https://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-265
# however pycrypto has no been updated since 2014... https://github.com/dlitz/pycrypto
#
# pyca/cryptography - https://cryptography.io/    https://github.com/pyca/cryptography
# seems to be currently maintained.
#
# Don't create your own encryption! The above packages or, openssl, or many other providers are
# better than writing your own.
#
# It is an exercise left to the reader to replace the code using lzma compression with real encrypt
# and decrypt code.  :)
# 
# 
import sqlite3
import hashlib
import os
from pathlib import Path
import lzma

# Salt should be random quantity, get from OS entropy source
salt = os.urandom(16);
mypasswd = b'JMP in a dried up lake'
dk = hashlib.pbkdf2_hmac('sha256', mypasswd, salt, 1000)
# dk.hex()  will be the actual hashed password saved to db
# but the binary dk, will be what we use as the encryption key
# dkhex = dk.hex()
# binDk = bytes.fromhex(dkhex)
# 

# Path to my credential store , my home directory + AppData
data_path = str(Path.home()) + '/AppData/'
filename = 'dataStore'

# Create directory if it doesn't exist
os.makedirs(data_path, exist_ok=True)

# will create database if it doesn't exist
db = sqlite3.connect(data_path + filename + '.db')

# my username
me = 'jmpuser'

# create our password table storing hashed passwords
db.execute('CREATE TABLE IF NOT EXISTS passwd (uid INTEGER PRIMARY KEY, name TEXT, salt TEXT, key TEXT)')

# should check to see if user is in database and only insert if not found
# exercise left to the reader
db.execute("INSERT INTO passwd (name, salt, key) VALUES( ?,?,? ) ", (me, salt.hex(), dk.hex()) )
db.commit()
print('******* passwd database *******')
for row in db.execute('SELECT * from passwd'):
    print(row)
print('*******************************')    

# create our credentials table which will store the name of the credential, and its value
db.execute('CREATE TABLE IF NOT EXISTS credentials (id INTEGER PRIMARY KEY, uid INTEGER, key TEXT, value TEXT)')

# first we need to have validated that user gave propper password, and we authenticated against passwd
# table assuming user is authenticated

# should check to see if user is in database and only insert if not found, potentially update if found
# exercise left to the reader.

# my user id in this scheme 
id = 0

#The value data I'm going to store into the database
myson1 = """
{
   user: paul
   magic_key: JMP Rocks!
}"""

myson2 = """
{
   user: paul
   magic_key: supercalifragilisticexpialidocious
}"""

# 'encrypt' my data
lvalue = lzma.compress( myson2.encode() )
lvalue2 = lzma.compress( myson1.encode() )

# you could encrypt the 'key' as well as the value if you really want security
db.execute("INSERT INTO credentials (uid, key, value) VALUES( ?,?,? ) ", (id, 'JMPCommunity', lvalue.hex()) )
db.execute("INSERT INTO credentials (uid, key, value) VALUES( ?,?,? ) ", (id, 'WDW', lvalue2.hex()) )
db.commit()
print('******* credentials database *******')
for row in db.execute('SELECT * from credentials WHERE uid=?', (id,) ):
    print(row)
    value = bytes.fromhex(row[3])
    print(lzma.decompress(value).decode())
print('************************************')
db.close()
&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 18:43:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/251411#M49355</guid>
      <dc:creator>Paul_Nelson</dc:creator>
      <dc:date>2020-03-09T18:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/273903#M53215</link>
      <description>&lt;P&gt;Found this while looking for a better solution for myself.&amp;nbsp; For scripts on my own machine, I call R and use the keyring function.&amp;nbsp; It uses Keychain on mac, Credential Store on Windows, and the Secret Service API on Linux.&amp;nbsp; Obviously this comes with overhead, it would be nice to do this without R.&amp;nbsp; If interested, I put a &lt;A href="https://community.jmp.com/t5/JMP-Wish-List/Create-functions-to-help-securely-store-and-retrieve-user/idi-p/273896" target="_self"&gt;JMP Wish List item to create these functions&lt;/A&gt;&amp;nbsp;in JMP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/r-lib/keyring" target="_blank" rel="noopener"&gt;https://github.com/r-lib/keyring&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;R Init();
R Submit(
	"library(keyring)
	pw &amp;lt;- keyring::key_get(\!"DomainAccount\!", \!"username\!")"
);
pw = R Get("pw");
R Term();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 21:33:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/273903#M53215</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-06-18T21:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/273964#M53218</link>
      <description>&lt;P&gt;I take an&amp;nbsp;&lt;SPAN&gt;obfuscation-style route.&amp;nbsp; I convert characters to numbers, then feed these numbers into a mathematical formula to generate an 'encrypted' representation.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I tend to use the technique more for software license codes rather than user passwords.&amp;nbsp; So I will take a product name or code combined with site ID information, plus an expiry date,&amp;nbsp; build a numeric representation and parse that through a complex mathematical formula: the final output might be something like&amp;nbsp;1143932720966.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 01:34:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/273964#M53218</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2020-06-19T01:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/274983#M53356</link>
      <description>&lt;P&gt;I like this.&amp;nbsp; I unfortunately can't force customers to install python (some have explicitly forbidden their users to install it).&amp;nbsp; But I have convinced most to install the sqlite odbc driver so maybe I can use that with MD5.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'd still have to find some way to do encryption.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for the help, I've definitely got some research to do.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:34:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/274983#M53356</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-06-23T13:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/274992#M53358</link>
      <description>You can look at doing encryption using a JMP add-in.  Understand that shipping an encryption library has legal and export ramifications.  Your best bet would be to write an add-in that calls into the native encryption libraries already on the host OS, and then still run it past your legal team.&lt;BR /&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:40:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/274992#M53358</guid>
      <dc:creator>Paul_Nelson</dc:creator>
      <dc:date>2020-06-23T13:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/275012#M53364</link>
      <description>&lt;P&gt;You've been more than helpful.&amp;nbsp; Thank you.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 14:36:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/275012#M53364</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-06-23T14:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/275290#M53419</link>
      <description>&lt;P&gt;On Windows I &lt;EM&gt;believe&lt;/EM&gt; this code could be re-created with JSL and the command line to interact with the windows credential manager, could be wrong.&amp;nbsp; Maybe someday I will take this on; sharing it here in case someone else figures it out first. :)&lt;/img&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="default prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="com"&gt;#include&lt;/SPAN&gt; &lt;SPAN class="str"&gt;&amp;lt;windows.h&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="com"&gt;#include&lt;/SPAN&gt; &lt;SPAN class="str"&gt;&amp;lt;wincred.h&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="com"&gt;#include&lt;/SPAN&gt; &lt;SPAN class="str"&gt;&amp;lt;tchar.h&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="com"&gt;#pragma&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; hdrstop

&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;void&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; main &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;()&lt;/SPAN&gt;
&lt;SPAN class="pun"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="pun"&gt;{&lt;/SPAN&gt; &lt;SPAN class="com"&gt;//--- SAVE&lt;/SPAN&gt;
        &lt;SPAN class="kwd"&gt;char&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;*&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; password &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="str"&gt;"brillant"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        DWORD cbCreds &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;1&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;+&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; strlen&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;password&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
        CREDENTIALW cred &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;{&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;};&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Type&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; CRED_TYPE_GENERIC&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;TargetName&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"FOO/account"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredentialBlobSize&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; cbCreds&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredentialBlob&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;LPBYTE&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; password&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;Persist&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; CRED_PERSIST_LOCAL_MACHINE&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;UserName&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"paula"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;
        BOOL ok &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;::&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredWriteW&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;cred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        wprintf &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"CredWrite() - errno %d\n"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; ok &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;?&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;::&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;GetLastError&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;());&lt;/SPAN&gt;
        &lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(!&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;ok&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;exit&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="pun"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="pun"&gt;{&lt;/SPAN&gt; &lt;SPAN class="com"&gt;//--- RETRIEVE&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        PCREDENTIALW pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        BOOL ok &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;::&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredReadW&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"FOO/account"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; CRED_TYPE_GENERIC&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        wprintf &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"CredRead() - errno %d\n"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; ok &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;?&lt;/SPAN&gt; &lt;SPAN class="lit"&gt;0&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;:&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;::&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;GetLastError&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;());&lt;/SPAN&gt;
        &lt;SPAN class="kwd"&gt;if&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(!&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;ok&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;)&lt;/SPAN&gt; &lt;SPAN class="kwd"&gt;exit&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="lit"&gt;1&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;        wprintf &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;L&lt;/SPAN&gt;&lt;SPAN class="str"&gt;"Read username = '%s', password='%S' (%d bytes)\n"&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; 
                 pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;UserName&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="kwd"&gt;char&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;*)&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredentialBlob&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredentialBlobSize&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;
        &lt;SPAN class="com"&gt;// must free memory allocated by CredRead()!&lt;/SPAN&gt;
        &lt;SPAN class="pun"&gt;::&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;CredFree&lt;/SPAN&gt; &lt;SPAN class="pun"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;pcred&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;);&lt;/SPAN&gt;
    &lt;SPAN class="pun"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="pun"&gt;}&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From kkm here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/9221245/how-do-i-store-and-retrieve-credentials-from-the-windows-vault-credential-manage" target="_blank"&gt;https://stackoverflow.com/questions/9221245/how-do-i-store-and-retrieve-credentials-from-the-windows-vault-credential-manage&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 20:40:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/275290#M53419</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2020-06-24T20:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: save passwords securely</title>
      <link>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/413323#M66301</link>
      <description>&lt;P&gt;Here is a version that uses an available module in powershell, maybe that is an option?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

loadmodule = "
		if (!(Get-Module -ListAvailable -Name CredentialManager)) {
			Install-Module CredentialManager -force -Scope CurrentUser
		}
		";


//Function to run command in powershell, strips trailing line breaks
RunPowershell = Function( {command},
	Regex(RunProgram(
		Executable( "powershell.exe" ),
		Options( {"/c", command } ),
		ReadFunction( "text" )
	), "^(.*?)[\r\n]+$", "\1")
);


// Set password
SetPass = Function( {target,user,pass},
	RunPowershell(
		"$target = '" || target || "'
		$usr = '" || user || "'
		$pswd = '" || pass || "'
		" || loadmodule || "
		New-StoredCredential -Target $target -UserName $usr -Password $pswd"
	);
	1; //password is returned as free text, don't return the response
);

// Get password
GetPass = Function( {target},
	RunPowershell(
		"$target = '" || target || "'
		" || loadmodule || "
		$creds = Get-StoredCredential -Target $target

		$creds.GetNetworkCredential().Password"
	)
);

// Get username
GetUser = Function( {target},
	RunPowershell(
		"$target = '" || target || "'
		" || loadmodule || "
		$creds = Get-StoredCredential -Target $target

		$creds.GetNetworkCredential().UserName"
	)
);

// Set and retrieve credentials
SetPass("testcredential", "myusername3", "mypassword3");
GetPass("testcredential");
GetUser("testcredential");

//You can delete these test credentials using the 'windows credential store'.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Aug 2021 22:10:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/save-passwords-securely/m-p/413323#M66301</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2021-08-27T22:10:06Z</dc:date>
    </item>
  </channel>
</rss>

