How is secure string encrypted? I've read that it uses DPAPI, but what if I'm using AsPlainText? Does it still uses DPAPI?
1 Answer
The article you linked to starts its second paragraph with:
The
ConvertFrom-SecureStringandConvertTo-SecureStringcmdlets, when you don’t use their -Key, -SecureKey, or -AsPlainText switches, use DPAPI to encrypt / decrypt your secret data.
So no, if you use -AsPlainText it is not encrypted and doesn't use DPAPI.
When it is encrypted, the key is specific to the user and computer on which you've done the encryption.
According to the ConvertFrom-SecureString documentation, if you use -Key or -SecureKey, then AES is used. As for how DPAPI encrypts data, have a look at this MSDN article about Windows Data Protection. One of its points says:
It uses proven cryptographic routines, such as the strong Triple-DES algorithm in CBC mode, the strong SHA-1 algorithm, and the PBKDF2 password-based key derivation routine.