title: How to encrypt using credentials of the current Windows user in powershell for KeePass?
body: <p>I need to write a script that encrypts a string the same way that the <a href="https://keepass.info/help/base/placeholders.html#passwordenc" rel="nofollow noreferrer"><code>{PASSWORD_ENC}</code>placeholder</a> is encrypted in KeePass:</p>
  
  <blockquote>
    <p>{PASSWORD_ENC} – Encrypting Passwords: </p>
    
    <p>The {PASSWORD_ENC} placeholder
    is replaced by the password of the current entry in encrypted form.
    <strong>The password is encrypted using credentials of the current Windows
    user.</strong> The encrypted password should not be stored and only works for
    the current user.</p>
  </blockquote>
  
  <p>(emphasis mine)</p>
  
  <p>How can I encrypt a string programmatically to get the same encrypted password as the one I would get in KeePass?</p>