libpurple2, surprisingly, gets that incorrect. The correct thing to do is use the OS-provided mechanisms. On Windows, that's CryptProtectData. That way the data, at rest, is inaccessible to anyone without the user's password.
But this doesn't apply to server applications like SMTP. I guess with SGX + some trusted storage, you could work it to only release the password to a known-encrypted socket or something.