If someone you do not want to know your password has direct access to the memory of a computer on which a password is known in plain text, you have failed completely at information security.
At some point, somewhere, your login information simply must exist in plain text. It doesn't have to be there for long, and it should never be persisted to long-term non-volatile memory in this form, but it is simply unfeasible to design a usable system of static credential entry that is invulnerable to "white box" snooping (where the attacker is assumed to have unlimited access to the state information of the machine and can analyse execution step by step). The user must be able to type in his password into a textbox, which stores that password plainly in memory (even if what it shows on screen is a series of bullets), and then your program must be able to retrieve it plainly before encoding it for transport to the authenticating system.
Similarly, something somewhere must know the key you are using to encrypt or decrypt. This, however, doesn't have to be your actual computer. HSMs were suggested; these are data processing modules designed to generate and store keys in a manner that doesn't require direct participation by the CPU or memory of the computer to which it's connected; an ideal black box. They're also designed to resist every effort to get inside this box, from any source including the computer it's connected to. The computer's just a proxy and a source of commands and input data to the HSM. However, that computer must still be trusted, to the extent that during any time an attacker can see and/or control what's being sent between the computer and HSM, he doesn't really need the data in the HSM to compromise your communication or even your key; he has a decryption oracle sitting right there for him to exploit.
If you are worried about keyloggers or other systems that could read a static password, then don't use one; instead, invest in RSA keytags or similar devices. These devices use an algorithm with a starting seed to generate a sequence of numbers, each one valid for one minute or so. The same algorithm, given the same seed value, is generating the same numbers on the server side. Type in the number you see on the tag (waiting for the next one if the current one is about to refresh) as your password. It doesn't really matter if you type that code in on a device that's obviously sending your keystrokes to a guy with a laptop a few feet away; that code will only work for one minute, and thoretically, he has an infinitesimal chance to correctly guess the next code, even if he knew every code that generator has ever produced.